解题思路:
注意事项:
参考代码:
#include<stdio.h>
#include<string.h>
//输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
int main()
{
int letter=0,space=0,number=0,other=0;
int i;
char s[100];
gets(s);//数组的输入
for(i=0;i<strlen(s);i++)//注意范围
{
if(s[i]>='A'&&s[i]<='Z'||s[i]>='a'&&s[i]<='z') //或这个符号||
letter++;
else if(s[i]==' ') //空格用单引号
space++;
else if(s[i]<='9'&&s[i]>='0')
number++;
else
other++;
}
printf("%d %d %d %d",letter,number,space,other);
}
0.0分
0 人评分
点我有惊喜!你懂得!浏览:1402 |
C语言训练-求矩阵的两对角线上的元素之和 (C语言代码)浏览:598 |
C语言训练-求素数问题 (C语言代码)浏览:1451 |
A+B for Input-Output Practice (IV) (C++代码)浏览:676 |
十->二进制转换 (C语言代码)浏览:1291 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:597 |
wu-理财计划 (C++代码)浏览:827 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:581 |
1908题解浏览:633 |
Tom数 (C语言代码)浏览:725 |