|
#include<stdio.h>//統計不同類型字符數
void main()
{char c;
int e=0,s=0,n=0,o=0;//這樣輸入是錯誤的:e=s=n=o=1,為什么呢?
printf("please input random characteristics,use enter to end the string\n");
for(;(c=getchar())!='\n';)//斜杠好像被我打反了
{
if((c>=65&&c<=90)||(c>=97&&c<=122))
e++;
else if((c>=48&&c<=57))
n++;
else if(c==32)
s++;
else
o++;
}
printf("the number of english characteristic is %d\n",e);
printf("the number of space is %d\n",s);
printf("the number of number is %d\n",n);
printf("the number of other characteristics is %d\n",o);
}
|
|