#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
void check_count();
int main() {
check_count();
return 0;
}
void check_count() {
int count_digit = 0, count_letter = 0, count_space = 0, count_other = 0;
char c;
printf("请输入一串字符!\n");
while ((c = getchar()) != '\n') {
if (c >= 'a' && c <= 'z' || c >= 'A' &&c <= 'Z') {
count_letter++;
}
else if (c == ' ') {
count_space++;
}
else if (c >= '0' && c <= '9') {
count_digit++;
}
else {
count_other++;
}
}
printf("\n统计结果:\n英文字母=%d\n空格=%d\n整数=%d\n其他字符=%d\n\n", count_letter, count_space, count_digit, count_other);
}