#include <stdio.h>
#include <stdlib.h>
#define N 100
void func3()
{
char str[N];
int i,upper=0,lower=0,digits=0,others=0;
printf("请输入一个字符串:");
gets(str);
for(i=0;str[i]!='\0';i++)
{
if(str[i]>='A' && str[i]<='Z')
upper++; /*统计大写英文字母*/
else if(str[i]>='a' && str[i]<='z')
lower++; /*统计小写英文字母*/
else if(str[i]>='0' && str[i]<='9')
digits++; /*统计字符串*/
else
others++; /*统计其他字母*/
}
printf("upper:%d\nlower:%d\ndigits:%d\nothers:%d\n",upper,lower,digits,others);
return 0;
}
int main()
{
while(1)
{
func3();
printf("\n");
system("pause");
}
return 0;
}
输出结果