题目:
问答题
程序的功能是?其中if块起什么作用?
#include
using namespace std;
int main()
{ int x;
cout << "enter choice(1-4):";
cin >> x;
while (x < 1 || x > 4)
{ cout << "Invalid choice, try again:";
cin >> x;
if ( !cin.good() )
{ cin.clear();
cin.sync();
cin >> x;
}
}
cout << "Had choice:" << x <<endl;
return 0;
}
答案:
<查看本题扣1积分>