解题思路:
多用用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 人评分
WU-输入输出格式练习 (C++代码)浏览:1076 |
C语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:915 |
【蟠桃记】 (C语言代码)浏览:1021 |
回文数字 (C语言代码)浏览:2509 |
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:984 |
printf基础练习 (C语言代码)浏览:1792 |
简单的a+b (C语言代码)浏览:434 |
A+B for Input-Output Practice (IV) (C语言代码)浏览:466 |
10月月赛题解浏览:536 |
C语言程序设计教程(第三版)课后习题10.7 (C++代码)浏览:649 |