0
Why my program did unexpected works ?
Fifrstly, by initialization one-dimensional vector? And then, by inserting ? https://code.sololearn.com/cty7k5CmiB4W/?ref=app Why nulls ?
6 odpowiedzi
+ 1
stamb does it work now?
https://code.sololearn.com/cIfg4MFsKQ9C/?ref=app
0
stamb I'm not really sure what you're trying to do, but here's code that 'works'
https://code.sololearn.com/cIfg4MFsKQ9C/?ref=app
Anyway, you should not use the end() iterator to access the last element, as it points past the end of the vector. Instead, use front() and back() to access the first and last elements.
I also noticed that in line 12, you initialized the vector with brackets rather than curly braces. Doing so initializes the size but not the elements.
0
Moses, Your variant is understanding, but it's not correct too.
0
stamb What is the program supposed to do?
0
I want to receive all array(i.e. four elements). Thus front() and back() not that. And so by initialized with {} (as you variant) will be first and last elements only, rather all array !
0
Correct, Moses. I know, it's simply.
But my question was about unexpected works my program!
And solution must be the ONE command (by initializes or Insert/Copy/Assign... or other).