#include void main(){ char new[]; inti,x=0,y=0,z=0,o=0; /**x为英文字符数y为空格字符数z数字个数,o其他字符树***/ printf("输入一个文本\n"); scanf("%s",new); for(i=0;new;i++) {
if(new>='1'&&new='a'&&new='A'&&newvoid main(){int i=0,chars=0,nums=0,spaces=0,others=0;char a[50];/*用来接收输入的字符串*/printf("请输入一行字符:\n");gets(a);while(a!='\0'){if ((a>='A' && a='a' && a='0' && a>pstr; curchar = pstr[0]; int curindex = 1; while(curchar != '\0') { if (curchar >= 65 && curchar = 128 || curchar = 48 && curchar <= 57) //0-9 numcount++; else if (curchar == 32) //空格 spacecount++; else othercount++; curchar = pstr[curindex++]; } totalcount = charcount + chinesecount + numcount + spacecount + othercount; cout<<"总数:"<<totalcount<<" 英文字符:"<<charcount<<" 中文字符"<<chinesecount <<" 数字:"<<numcount<<" 空格:"<<spacecount<<" 其它:"<<othercount; }//我转载的参考资料:http://zhidao.baidu.com/question/5760725.html
已赞过已踩过<这里有现成的答案:http://hanlin.hbu.cn/personal/gbz/xiti.htm |