/*
vc2022
解题思路:
1.定义相关变量并初始化
2.当读入的不是字符ch不是回车字符
{
if(ch是字母),letter加一
以此类推
}
输出letter,digit,other
*/
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main(void)
{
int digit, letter, other;
char ch;
digit = 0;
letter = 0;
other = 0;
printf("请输入一些字符串,当输入回车时表示结束\n");
while (ch = getchar(), ch != '\n') //
{
if (ch >= 'a' && ch < 'z' || ch>'A' && ch <= 'Z')//ch是字母
letter++;
else if (ch >= '1' && ch <= '9')//ch是数字
digit++;
else
other++;//其他字符
}
printf("letter:%d digit:%d other:%d\n", letter, digit, other);
return 0;
}