题目:输入一个字符串,统计字符串中大、小写字母,数字及其他字符出现的次数
代码解释:
#include <stdio.h>
int main() {
char chuan[1000];
scanf("%s", chuan);
int big = 0, small = 0, number = 0, other = 0, i = 0;
for (; chuan[i] != 0; ++i) {
if (chuan[i] > 'A' && chuan[i] < 'Z') {
big = big + 1;
continue;
}
if (chuan[i] > 'a' && chuan[i] < 'z') {
small = small + 1;
continue;
}
if (chuan[i]>='0'&&chuan[i<='9']) {
number = number + 1;
continue;
}
other = other + 1;
}
printf("%d ", big);
printf("%d ", small);
printf("%d ", number);
printf("%d\n", other);
return 0;
}