標(biāo)題: c語言 統(tǒng)計(jì)不同類型字符數(shù) [打印本頁] 作者: liuda 時(shí)間: 2015-1-22 02:46 標(biāo)題: c語言 統(tǒng)計(jì)不同類型字符數(shù) #include<stdio.h>//統(tǒng)計(jì)不同類型字符數(shù) void main() {char c; int e=0,s=0,n=0,o=0;//這樣輸入是錯(cuò)誤的: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); }