首页 > 解决方案 > 我是 C++ 的初学者,我想知道我的代码中的错误

问题描述

#include <iostream>

using namespace std;

int main()

{
    cout << "entre two numbers";
    double x, y;
    cin >> x >> y;

    if (x != y)
        if (x % 2 == 0)
            if (y % 2 == 0)
                cout << "the two numbers are accepted";
            else
                cout << "the two numbers are not accepted";

    return 0;
}

标签: c++

解决方案


您必须声明 'int' 类型的变量而不是 double,这样您的错误就会得到解决。

写在下面一行。整数 x,y;


推荐阅读