C语言,输入一个字符,判断它是英文字符,数字字符还是其他字符.

2025-01-04 07:23:03
推荐回答(2个)
回答1:

#include

int main()
{
char p;
scanf("%c",&p);
if(p>='a' && p<='z' || p>='a' && p<='z')
printf("英文字符\n");
else if(p>='0' && p<='9')
printf("数字字符\n");
else
printf("其他字符\n");

return 0;
}

回答2:

#include
main()
{
char c;
scanf("%c",&c);
if(c>='A' && c<='Z' || c>='a' && c<='z')
printf("%c is alphabet\n", c);
else if(c>='0' && c<='9')
printf("%c is number\n", c);
else
printf("%c is other character\n", c);
}