我正在努力让代码检查用户输入是否介于(包括)10 和 100 之间。
太习惯于单一输入,我遇到了麻烦,因为它是一个数组...
int main()
{
int numlist[20];
for(int i = 0; i < 20; i++)
{
cout << "Enter # " << i + 1 << " : ";
// here is where I am going wrong...
if ((numlist[i] <= 100) && (numlist[i] >= 10))
{
cin >> numlist[i];
}
}
}
最佳答案
你不应该把输入语句cin >> numlist[i]
之前测试if ((numlist[i] <= 100) && (numlist[i] >= 10))
?
关于c++ - 如何为此代码创建支票?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8001273/