循环语句问题
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(void){
int i = 0;
int k = 0;
int s = 0;
int n;
if (s < 10){
cin >> n;
switch (n)
{
case 8:
i++;
cout << "accelerate" << "\n"; break;
case 5:
i--;
cout << "brake" << "\n"; break;
case 4:
k -= 1;
cout << "turn left" << "\n"; break;
case 6:
k += 1;
cout << "turn right" << "\n"; break;
}
n = 0;
s = s + i;
if (k == 0 && s == 3){
cout << "Turn left please" << "\n";
cin >> n;
if (n == 4) k++;
else{
cout << "crash" << "\n";
goto last;
}
}
if (k == 1 && s == 7){
cout << "Turn right please" << "\n";
cin >> n;
if (n == 6) k--;
else{
cout << "crash" << "\n";
goto last;
}
}
}
if (s == 10){
cout << "Your win" << "\n";
s++;
}
last: cout << "game over" << "\n";
std::system("pause");
return 0;
}
请问各位大神 为什么我输出8后直接 accelerate + game over 了