偶数除以 2 的余数为 0,因此使用 n % 2 == 0 判断。
2
0
n % 2 == 0
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; bool isEven = n % 2 == 0; cout << boolalpha << isEven << endl; return 0; }
使用您的 椰子OJ CoconutOJ 通用账户