Look at this code:
#include
#include
int main()
{
int count_num = 0, count_ABC = 0, count_abc = 0, count_others = 0;
int i = 0;
char str[255];
scanf("%s", &str);
i = 0;
while (str[i])
{
printf("%c", str[i]);
int ASC = str[i];
if (ASC >= 65 && ASC <= 90)//大写字母
count_ABC++;
else if (ASC >= 97 && ASC <= 122)//小写字母
count_abc++;
else if (ASC >= 48 && ASC <= 57)//数字
count_num++; else
count_others++;
i++;
}
printf("大写字母个数:%d\n小写字母个数:%d \n数字个数:%d\n 其他:%d\n", count_ABC, count_abc, count_num, count_others);
return 0;
}