解题思路:
多用用ctype里面的函数就行了
注意事项:
要现用isgraph函数,再用isgraph函数,不然会全部归类为isgraph函数的数上
参考代码:
#include <stdio.h>
#include <ctype.h>
#define maxn 1010
char a[maxn];
int main()
{
int eng = 0,num = 0,kong = 0,other = 0;
gets(a);
for(int i = 0; a[i] != '\0'; i++){
if(isalpha(a[i])) eng++;
else if(isdigit(a[i])) num++;
else if(isgraph(a[i])) other++;
else kong++;
}
printf("%d %d %d %d",eng,num,kong,other);
return 0;
}
0.0分
4 人评分
C语言考试练习题_排列 (C语言代码)浏览:1317 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:1156 |
Wu-求圆的面积 (C++代码)浏览:1887 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:637 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:588 |
大神老白 (C语言代码)浏览:600 |
Quadratic Equation (C语言代码)浏览:988 |
C语言训练-大、小写问题 (C语言代码)浏览:677 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:512 |
1134题解(求分析)浏览:725 |