#include <stdio.h>
#include <stdlib.h>
void main(){
int number=0,other=0,space=0;
char as[500],*ps;
int f[27];
FILE *fp;
if((fp=fopen("E:\\english.txt","r"))==NULL){
printf("cannot open file.\n");
exit(0);
}
fgets(as,499,fp);
fclose(fp);
for(int i=0;i<28;i++){
f[i]=0;
for( ps=as;*ps!='\0';ps++)
if( *ps=='A'||*ps=='a')
f[0]++;
else if( *ps=='B'||*ps=='b')
f[1]++;
else if( *ps=='C'||*ps=='c')
f[2]++;
else if( *ps=='D'||*ps=='d')
f[3]++;
else if( *ps=='E'||*ps=='e')
f[4]++;
else if( *ps=='F'||*ps=='f')
f[5]++;
else if( *ps=='G'||*ps=='g')
f[6]++;
else if( *ps=='H'||*ps=='h')
f[7]++;
else if( *ps=='I'||*ps=='i')
f[8]++;
else if( *ps=='J'||*ps=='j')
f[9]++;
else if( *ps=='K'||*ps=='k')
f[10]++;
else if( *ps=='L'||*ps=='l')
f[11]++;
else if( *ps=='M'||*ps=='m')
f[12]++;
else if( *ps=='N'||*ps=='n')
f[13]++;
else if( *ps=='O'||*ps=='o')
f[14]++;
else if( *ps=='P'||*ps=='p')
f[15]++;
else if( *ps=='Q'||*ps=='q')
f[16]++;
else if( *ps=='R'||*ps=='r')
f[17]++;
else if( *ps=='S'||*ps=='s')
f[18]++;
else if( *ps=='T'||*ps=='t')
f[19]++;
else if( *ps=='U'||*ps=='u')
f[20]++;
else if( *ps=='V'||*ps=='v')
f[21]++;
else if( *ps=='W'||*ps=='w')
f[22]++;
else if( *ps=='X'||*ps=='x')
f[23]++;
else if( *ps=='Y'||*ps=='y')
f[24]++;
else if( *ps=='Z'||*ps=='z')
f[25]++;
else if( *ps<='9'&&*ps>='0')
number++;
else if(*ps==' ')
space++;
else other++;
}
printf("a=%d b=%d c=%d d=%d e=%d \n",f[0],f[1],f[2],f[3],f[4]);
printf("f=%d i=%d j=%d k=%d l=%d \n",f[5],f[6],f[7],f[8],f[9]);
printf("m=%d n=%d o=%d p=%d q=%d \n",f[10],f[11],f[12],f[13],f[14]);
printf("r=%d s=%d t=%d u=%d v=%d \n",f[15],f[16],f[17],f[18],f[19]);
printf("w=%d x=%d y=%d z=%d number=%d space=%d other=%d \n",f[20],f[21],f[22],f[23],f[24],f[25],number,space,other);
}
|