用c语言对中文文档,统计文中的标点符号的个数,空格的个数,字符的个数.

在线等....希望能尽快回答..
中文文档啊....

第1个回答  2009-12-25
#include <stdio.h>
#include <stdlib.h>
void main()
{ int upper=0,lower=0,number=0,other=0,space=0;
char as[200],*ps;
FILE *fp;
if((fp=fopen("昨天.txt","r"))==NULL)
{ printf("cannot open file.\n");
exit(0); }
fgets(as,199,fp);
fclose(fp);
for( ps=as;*ps!='\0';ps++)
if( *ps<='z'&&*ps>='a') lower++;
else if( *ps<='Z'&&*ps>='A') upper++;
else if( *ps<='9'&&*ps>='0') number++;
else if(*ps==' ') space++;
else other++;
printf("%d %d %d %d %d",upper,lower,number,space,other);

}

vc++中通过
昨天.txt 中内容为 cnisdvs ./ '7 6 9 986554

输出结果 0 7 9 5 3本回答被提问者采纳