给你全写了,自己看看吧,很简单的。你应该会的,
www.my-java.comIT啦
www.it-la.com统计大写字母、小写字母、空格、数字和其它字符的数目。
#include<stdio.h>
#define N 50
void main()
{
char str[N];
int i,dx,xx,sz,kg,qt;
dx=xx=sz=kg=qt=0;
printf("\nInput:");
gets(str);
for(i=0;str[i]!='\0';i++) /*当出现结束符时结束循环*/
{ if(str[i]>=65&&str[i]<=90) /*使用ASCII码判断字符*/
dx++;
else if(str[i]>=97&&str[i]<=122)
xx++;
else if(str[i]==32)
kg++;
else if(str[i]>=48&&str[i]<=57)
sz++;
else qt++;
}
printf("The total: A-Z are %d,a-z are %d,0-9 are %d,space are %d,other are %d.",dx,xx,sz,kg,qt);
}