输入一个字符串,分别统计字符串中,ASCII值为奇数和偶数的字符个数并输出.

c语言程序

#include<stdio.h> #include<string.h> main() { inti,n1=0,n2=0; charstr[80]; printf(" 请输入字符串: "); gets(str); for(i=0;str[i]!='\0';i++) { if(str[i]%2==1) n1++; else n2++; } printf("ASII 值为奇数的有 %d 个 \nASII 值为偶数的有 %d 个 \n",n1,n2); }
温馨提示:答案为网友推荐,仅供参考
相似回答