c++ - 如何为此代码创建支票?

标签 c++ constraints

我正在努力让代码检查用户输入是否介于(包括)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/

相关文章:

ios - 异步调整 UITableViewCell 与生成的 UIView-Encapsulated-Layout-Height

c++ - 如何在屏幕的一部分插入图像?

python - 如何创建 "at least n"约束?

mysql - Mysql中的两列在column1和column2之间具有唯一性约束

c++ - AABB Collision response(推回碰撞物体)

ios - Swift:使用约束平移 UIImage

database - 有额外约束的外键?

c++ - 在自身内部定义类的标准实例 (C++)

C++ sdl : can i have an sdl-opengl window inside a menu and buttons i created with glade?

C++ 类型转换顺序/正确的代码格式?