c++初学看看哪里有错误
来源:百度知道 编辑:UC知道 时间:2024/07/04 10:47:04
#include <iostream.h>
int main(int argc, char* argv[])
{
int num;
cout << "请输入一个整数:";
cin >> num;
if((num % 2) == 0)
cout << num << "是一个偶数。" << endl;
else
cout << num << "是一个奇数。" << endl;
getchar();
return 0;
}
哪里有错误呢.
int main(int argc, char* argv[])
{
int num;
cout << "请输入一个整数:";
cin >> num;
if((num % 2) == 0)
cout << num << "是一个偶数。" << endl;
else
cout << num << "是一个奇数。" << endl;
getchar();
return 0;
}
哪里有错误呢.
getchar()错了,把这个给删除了,没必要
或者你实在想要它的话,加个
#include <stdio.h>
要是想停的话,直接用个cin.get()或者system("pause");就可以了~~~