实现效果如下:
下面是实现方法:
# include <iostream>
# include <string> //这里需要添加字符串头文件
using namespace std;
int main()
{
int a, b;
cin >> a, b;
string str;
str = (a % 2 != 0) ? "奇数" : "偶数"; //这里运用了三目运算符
cout << str << endl;
system("pause");
return 0;
}
先介绍到这里,欢迎大家在评论区留言~