I have 3 arrays which contains 5 elements each (max size is 5). What I wanted to do is to insert an item, e.g, to position 7. The end result is the item should be placed in 2nd array at index 2 and a 4th array is then created with 1 element (from last item of 3rd array).
result
array1 array1
- item1 (position 0) - item1 (position 0)
- item2 (position 1) - item2 (position 1)
- item3 (position 2) - item3 (position 2)
- item4 (position 3) - item4 (position 3)
- item5 (position 4) - item5 (position 4)
array2 array2
- item1 (position 5) - item1 (position 5)
- item2 (position 6) - item2 (position 6)
- item3 (position 7) - item3 (position 7) -> new_item
- item4 (position 8) - item4 (position 8)
- item5 (position 9) - item5 (position 9)
array3 array3
- item1 (position 10) - item1 (position 10)
- item2 (position 11) - item2 (position 11)
- item3 (position 12) - item3 (position 12)
- item4 (position 13) - item4 (position 13)
- item5 (position 14) - item5 (position 14)
array4
- item1 (position 15)
And, if wanted to get the item at position 12, then the result should be item3 of array3.
How can I do this in c++?
Aucun commentaire:
Enregistrer un commentaire