统计字符
统计字符
/problem-sets/12/problems/273
#include<stdio.h>
int main(void)
{
int i;char ascii;
int letter=0,blank=0,digit=0,other=0;
for(i=1;i<=10;i++)
{
ascii = getchar();
if(ascii>=48&&ascii<=57)digit++;
else if(ascii>=65&&ascii<=90)letter++;
else if(ascii>=97&&ascii<=122)letter++;
else if(ascii==10||ascii==32)blank++;
else other++;
}
printf("letter = %d, ",letter);
printf("blank = %d, ",blank);
printf("digit = %d, ",digit);
printf("other = %d",other);
return 0;
}
浙公网安备 33010602011771号