int main(){
int enter=0;
while(enter!=1&&enter!=2&&enter!=3&&enter!=4){
cout<<"Please select one of the following options:\n"
<<"1: Play\n"
<<"2: Help\n"
<<"3: Config\n"
<<"4: Quit\n"<<endl;
cin>>enter;
if(enter==1){
cout<<"you have selected play."<<endl;
}else if(enter==2){
cout<<"you have selected help."<<endl;
}else if(enter==3){
cout<<"you have selected config."<<endl;
}else if(enter==4){
cout<<"you have selected quit."<<endl;
}else if(enter>4||enter<1){
cout<<"your selection must be between 1 and 4!"<<endl;
}else {
cout<<"you have not entered a number!"<<endl;
return 0;
...怎么解决 其中我还要判断enter这个是否在1-4之间 用string的话就无法...
将enter定义为char不就行了,而且何必这么多的if else呢,直接switch多好
c++ 为什么打入字母会死循环 怎么解决
试图读取整数,没有读到,只要把输入缓冲区清空了继续读就可以了,空格等也是字符,读整数包括浮点数时,如果有空白符会被跳过,但会不自动跳过非空白非数字字符,你得主动点,一句 cin.clear(); 就清空了全部...或者你这里干脆不要用整型接收,直接用字符接收,比较时用字符,输入非期望字符时直接让重...
用C++函数描述个算法,并求出时间复杂度
include<iostream.h> int max=0,may=0;int array[5][5];void ReMax(){ int i,j;\/\/\/冒泡法,时间复杂度为5*5 for(i=0;i<5;i++)for(j=0;j<5;j++)if(array[max][may]<array[i][j+1]){max=i;may=j+1;} } void main(){ int i,j;\/\/*a=(int*)malloc(5*sizeof(in...