c++ - 我是 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;
}
解决方案
您必须声明 'int' 类型的变量而不是 double,这样您的错误就会得到解决。
写在下面一行。整数 x,y;
推荐阅读
- java - 使用 Java 比较两个文件并分别存储有用信息
- python - Python WindowsError: [错误 123] 文件名、目录名或卷标语法不正确
- swift - 当毫秒具有小数值(000 以外的值)时,Swift 日期字符串到日期失败
- codeigniter - 如何在codeigniter中导出包含数据的csv文件?
- kotlin - Reactor - 加载分页 API 的所有页面
- sql-server - 是否可以定期将数据从本地 SQL Server 数据库复制到在线 SQL Server 数据库,反之亦然?
- java - 在接收数组的方法中分配两个数组
- java - Java 为什么 DatagramPacket 的构造函数需要字节数组的长度?
- java - 在元音和辅音之间添加空格?
- python - 尝试直接在 S3 中创建 CSV 文件并在 CSV 中写入数据