功能:输入一篇文章,让你统计字符个数,程序编译通过,执行有问题
#include <stdio.h>
#include <string.h>
void main()
{
void str_count(char str[]);
char str[100000];
int i,J;
J=strlen(str);
for (i=0;i<=J;i++)
gets (str[i]);
str_count(str[0]);
}
void str_count(char str[],int J)
{
int T,a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;
for (T=0;T<J;T++)
if(str[i]='a') a=a+1;
else if(str[i]='b')b=b+1;
else if(str[i]='c')c=c+1;
else if(str[i]='d')d=d+1;
else if(str[i]='e')e=e+1;
else if(str[i]='f')f=f+1;
else if(str[i]='g')g=g+1;
else if(str[i]='h')h=h+1;
else if(str[i]='i')i=i+1;
else if(str[i]='j')j=j+1;
else if(str[i]='k')k=k+1;
else if(str[i]='l')l=l+1;
else if(str[i]='m')m=m+1;
else if(str[i]='n')n=n+1;
else if(str[i]='o')o=o+1;
else if(str[i]='p')p=p+1;
else if(str[i]='q')q=q+1;
else if(str[i]='r')r=r+1;
else if(str[i]='s')s=s+1;
else if(str[i]='t')t=t+1;
else if(str[i]='u')u=u+1;
else if(str[i]='v')v=v+1;
else if(str[i]='w')w=w+1;
else if(str[i]='x')x=x+1;
else if(str[i]='y')y=y+1;
else if(str[i]='z')z=z+1;
printf("\na:%d\nb:%d\nc:%d\nd:%d\ne:%d\nf:%d\ng:%d\nh:%d\ni:%d\nj:%d\nk:%d\nl:%d\nm:%d\nn:%d\no:%d\np:%d\nq:%d\nr:%d\ns:%d\nt:%d\nu:%d\nv:%d\nw:%d\nx:%d\ny:%d\nz:%d",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z);
}