题目标题:
一清二楚
题目描述:
输入一字符串,该字符串包含字母、数字和其他字符。统计该字符串中数字、字母和其他字符出现的频率。(注意,其他字符包含空格)
输入描述:
一混合字符串,最大长度为200 各类字符出现频率
输出描述:
各类字符出现频率
样式输入:
abcdefg9999////
样式输出:
ch:7
num:4
other:4
#include<stdio.h>
#include<string.h>
int main()
{
char a[205]={0};
gets(a); /*
不用scanf,有空格的要用gets*/
int i,l=strlen(a),ch=0,num=0,other=0;
for(i=0;i<l;i++)
{
if(a[i]>='a'&&a[i]<='z'||a[i]>='A'&&a[i]<='Z')
ch++;
else if(a[i]>='0'&&a[i]<='9')
num++;
else other++;
}
printf("ch:%d\nnum:%d\nother:%d",ch,num,other);
return 0;
}