主题:请大家帮忙看看这个程序什么问题啊,谢谢
#include <stdio.h>
int Zimu,Kongge,Shuzi;
main()
{int tongji(char b[],int n);
char a[10];
int i,j,qita;
printf("entry a sery char:");
for (i=0;(a[i]=getchar())!='\n';i++)
printf("%c\n",a[i]);
qita=tongji(a,i);
printf("zimu=%d\nkongge=%d\nshuzi=%d\nkongge=%d\nqita=%d\n",Zimu,Kongge,Shuzi,qita);
}
int tongji(char b[],int n)
{int i,Zimu=0,Shuzi=0,Kongge=0,qita=0;
for (i=0;i<n;i++)
{if ((b[i]<='z'&&b[i]>='a')||(b[i]<='Z'&&b[i]>='A')) Zimu++;
else if(b[i]==32) Kongge++;
else if(b[i]>=48&&b[i]<=57) Shuzi++;
else qita++;}
return (qita);
}
运行之后发现全局变量的结果根本就不对
int Zimu,Kongge,Shuzi;
main()
{int tongji(char b[],int n);
char a[10];
int i,j,qita;
printf("entry a sery char:");
for (i=0;(a[i]=getchar())!='\n';i++)
printf("%c\n",a[i]);
qita=tongji(a,i);
printf("zimu=%d\nkongge=%d\nshuzi=%d\nkongge=%d\nqita=%d\n",Zimu,Kongge,Shuzi,qita);
}
int tongji(char b[],int n)
{int i,Zimu=0,Shuzi=0,Kongge=0,qita=0;
for (i=0;i<n;i++)
{if ((b[i]<='z'&&b[i]>='a')||(b[i]<='Z'&&b[i]>='A')) Zimu++;
else if(b[i]==32) Kongge++;
else if(b[i]>=48&&b[i]<=57) Shuzi++;
else qita++;}
return (qita);
}
运行之后发现全局变量的结果根本就不对