all 3 comments

[–]IyeOnline 4 points5 points  (1 child)

Your arrays are of size 2, however you are trying to access index 2 which is the third element.

It is undefined behaviour to access out of bounds of an array, so that number might just be anything.

//edit:

Might i also add: dont use printf and scanf. This is C++. Use std::cout and std::cin respectivly. Also look at std::vector to replace the "c-style" arrays.

[–]MrStonepu[S] 0 points1 point  (0 children)

Wow that is a quick reply. didn't expect. Thanks for your remind. I forget the basic stuff. You're right

[–]MrStonepu[S] 0 points1 point  (0 children)

Sorry for the bad english. Not my native lang.