解题思路:
用ctype.h的字符判断函数
注意事项:
参考代码:
#include<stdio.h>
#include<ctype.h>
int main(void)
{
int i_letter=0;
int i_number=0;
int i_space=0;
int i_other=0;
int c;
printf("Please enter a string:");
while((c=getchar())!='\n')
{
if(isalpha(c))
i_letter++;
else if(isdigit(c))
i_number++;
else if(isblank(c))
i_space++;
else
i_other++;
}
printf("%d %d %d %d\n",i_letter,i_number,i_space,i_other);
return 0;
}
0.0分
0 人评分
字符串输入输出函数 (Java代码)浏览:1437 |
DNA (C语言描述,数据结构)浏览:850 |
简单的a+b (C语言代码)浏览:596 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:460 |
printf基础练习2 (C语言代码)浏览:617 |
1908题解浏览:633 |
C语言训练-自守数问题 (C语言代码)浏览:740 |
最好的,浏览:563 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:549 |
字符删除 (C语言代码)浏览:715 |