C语言课后习题(59)
谭浩强C语言第五版的一些课后习题第八章 第八题输入一行文字,统计大写 小写 空格 数字 其他 的个数int main(){int up=0,low=0,dig=0,space=0,other=0;int i=0;char *p,str[30];printf("输入一行字符串:\n");gets(str);p=str;while(*p!='\0'){if((*p>='A')&&
·
谭浩强C语言第五版的一些课后习题
第八章 第八题
输入一行文字,统计大写 小写 空格 数字 其他 的个数
int main(){
int up=0,low=0,dig=0,space=0,other=0;
int i=0;
char *p,str[30];
printf("输入一行字符串:\n");
gets(str);
p=str;
while(*p!='\0'){
if((*p>='A')&&(*p<='Z')) up++;
else if((*p>='a')&&(*p<='z')) low++;
else if((*p>='0')&&(*p<='9')) dig++;
else if(*p==' ') space++;
else other++;
p++;
}
printf("大写:%d\t小写:%d\t数字:%d\t空格:%d\t其他:%d\n",up,low,dig,space,other);
}
更多推荐



所有评论(0)