解题思路:
注意事项:
参考代码:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int i,m;
int letter=0;
int space=0;
int num=0;
int other=0;
char str[100];
gets(str);
m=strlen(str);
for(i=0; i<m; i++)
{
if((str[i]>=65&&str[i]<=90)||(str[i]>=97)&&(str[i]<=122))
letter++;
else if(str[i]==' ')
space++;
else if(str[i]>=48&&str[i]<=57)
num++;
else
other++;
}
printf("%d %d %d %d\n",letter,space,num,other);
return 0;
}
0.0分
0 人评分
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C++代码)(手动优化一下计算)浏览:1274 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:594 |
WU-字符串比较 (C++代码)浏览:752 |
字符逆序 (C语言代码)浏览:455 |
蚂蚁感冒 (C语言代码)浏览:753 |
局部变量作函数返回值的问题浏览:963 |
C语言程序设计教程(第三版)课后习题12.6 (C语言代码)浏览:641 |
C语言程序设计教程(第三版)课后习题6.7 (C语言代码)浏览:672 |
简单的a+b (C语言代码)浏览:506 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:548 |