I'm new to programming in C++. I've been trying to create a program that reads integers as long as they are alternately positive and negative. I don't know how to make it without using if in if, and because of that it can read e.g (2, -2, 2, -2, -2, -2).
int temp = 0, x = 0, y = 0;
while (temp == 0){
cin >> x;
if (x > 0) {
y = x;
cin >> x;
if (x < 0)
continue;
else if(y > 0 && x > 0)
break;
}
if(x < 0){
y = x;
cin >> x;
if (x > 0)
continue;
else if(y < 0 && x < 0)
break;
}
}