从键盘输入一个字符,判断其是字母字符,还是数字字符,还是其他字符,输出判断结果 C语言求大神

如题所述

可以参考下面的代码:

#include "stdio.h"

void main()

{

char temp;

temp=getch();

if(temp>='a'&&temp<='z')

printf("xiao xie zi mu");

else if(temp>='A'&&temp<='Z')

printf("da xie zi mu");

if(temp>='0'&&temp<='9')

printf("shuzi");

else printf("other zi mu");

}

扩展资料:

C语言函数参考

int isupper(int ch) 若ch是大写字母('A'-'Z')返回非0值,否则返回0

int isxdigit(int ch) 若ch是16进制数('0'-'9','A'-'F','a'-'f')返回非0值,否则返回0

int tolower(int ch) 若ch是大写字母('A'-'Z')返回相应的小写字母('a'-'z')

int toupper(int ch) 若ch是小写字母('a'-'z')返回相应的大写字母('A'-'Z')

参考资料来源:百度百科-c语言

温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-09-14

#include<stdio.h>

void main()

{

char ch;

printf("Please type in a character:");

ch=getchar();

if(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z')

printf("字母\n");

else if(ch>='0'&&ch<='9')

printf("数字\n");

else

printf("其他\n");

}

本回答被提问者采纳
第2个回答  2015-04-10
可以查看ascll 表,然后用if判断
第3个回答  2021-01-02

第4个回答  2015-04-10
查ASCII表