编程,输入一行字符,以“\n”结束。分别统计出其中英文字母、空格、数字和其它字符的个数。


请帮帮忙!作了好几节课了。。。。。用C写!
#include <stdio.h>
void main()
{char ch;
int alpha,space,number,another;
alpha=space=number=another=0;
printf("Enter: ");
while((ch=getchar())!='\败如扰n')
{if(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z') alpha++;
else if(ch==' ') space++;
else if(ch>='0'察旦&&ch<='9') number++;
else another++;
}
printf("橡衡alpha=%d,space=%d,number=%d,another=%d",alpha,space,number,another);
}
#include<stdio.h>
#define N 100
void main()
{ char string[N]
int i,num=0,word=0,zifu,shuzi,qita;
char c;
gets(string);
for(i=0;(c=string[i]!='\n';i++);
{
if(c>='雀中岩A'&&c<='z'培竖)
zifu++;
else if(c>='a'&&c<='z')
zifu++;
else if(c>='0'&&c<='9')
shuzi++;
else qita++;
}
print("%5d,%5d,%5d"顷御,zifu,shuzi,qita);
}