我想用输入y来做保存,用r做恢复,但是我把它写在下面的代码中,然后我输入y或r,我只是要注意““请输入两个正数”这一行代码“if(x==(int)('y'))”和下一行被忽略。怎么会发生这种情况
int main(){
cout<<"It's player_"<<player+1<<"'s turn please input a row and col,to save and exit,input y,resume game input r"<<endl;
while(true){
cin>>x;
if(x==(int)('y')) {save();has_saved=true;break;}
if(x==(int)('r')) {resume();has_resumed=true;break;}
cin>>y;
if(cin.fail()){
cout<<"Please enter two positve numbers"<<endl;
cin.clear();
cin.sync();}
else {
chessboard[x][y]=player_symbol[player+1];
break;
}
}
}