当前位置:网站首页>Noi OJ 1.4 04: odd even ASCII value judgment C language

Noi OJ 1.4 04: odd even ASCII value judgment C language

2022-06-23 10:29:00 chd44

describe

Enter any character , Judge it ASCII Is it an odd number , if , Output YES, otherwise , Output NO
for example , character A Of ASCII The value is 65, The output YES, If you enter a character B(ASCII The value is 66), The output NO

Input

Enter a character

Output

If it ASCII The value is odd , The output YES, otherwise , Output NO

Pay attention to the topic ( Huangzi part ), Don't leave out the conditions .

Because there are two cases where the output is NO, We use it if  elseif  Connect the two situations , be left over YES In this case, we use else To express .

#include<stdio.h>
int main(){
char a;
scanf("%c",&a);
int b=a;
int c=b%2;
if (b>65)
    printf("NO");
else if (c==0)
    printf("NO");
else
    printf("YES");
return 0;
}

原网站

版权声明
本文为[chd44]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231012355876.html