qfedu-basic-level/day9/d4_2.cpp

24 lines
360 B
C++
Raw Permalink Normal View History

2023-06-26 08:34:05 +08:00
// 判断给定的整数是否为偶数
#include <iostream>
using namespace std;
int isEven(int *n)
{
if (*n % 2 == 0)
return 1;
return 0;
}
int main()
{
int n;
cout << "请输入一个整数:";
cin >> n;
if (isEven(&n))
cout << "是偶数" << endl;
else
cout << "不是偶数" << endl;
return 0;
}