如何使CIN只取数字
double enter_number(){ double number; while(1) { cin>>number; if(cin.fail()) { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout << "Invalid input " << endl; } else break; cout<<"Try again"<<endl; } return number;}
守候你守候我
相关分类