编写程序C语言 从键盘输入一个字符,判断是字母,数字,还是其它字符

如题所述

用ASCII码判断就行,一个字符对应一个整型数,或调用库函数ctype
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-09-28
#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");
}本回答被提问者采纳
第2个回答  2008-11-22
#include "stdio.h"
#include "bios.h"
#include "ctype.h"
main(){
int key;
key=bioskey(0);
if(isalnum(key&0xff)){
if(((char)key>='a'&&(char)key<='z')||((char)key>='A'&&(char)key<='Z'))
printf("you input a char.\n");
else
printf("you input a number.\n");
}
else
printf("you input a teshu zifu.");

getch();
}
第3个回答  2008-11-22
#include<stdio.h>
main()
{char c;
c=getchar()
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
printf("it is ");
else if(c>='0'&&c<='9')
printf("it is a number");
else printf("it is others");}

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网