0
点赞
收藏
分享

微信扫一扫

大数的奇偶性判断


题目描述
​ 从键盘输入一个位数可能达到 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;
}


举报

相关推荐

0 条评论