题目描述
从键盘输入一个位数可能达到 10000 位的整数,判断它是否是一个偶数,如果是偶数输出 YES,否则输出 NO。
输入
输入一行,包含一个正整数。(长度小于 10000)
输出
如果是偶数输出 YES 否则输出 NO。
#include <stdio.h>
#include <string.h>
int main() {
char str[10000];
scanf("%s", &str);
if ((str[strlen(str) - 1] - '0' )& 1) printf("NO\n");
else printf("YES\n");
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
cin >> str;
if ((str[str.size() - 1] - '0') % 2) {
cout << "NO" << endl;
}
else cout << "YES" << endl;
return 0;
}