数字0-9的ASCII码为:048到057
大写字母A-Z的ASCII为:065-090
小写字母a-z的ASCII为:097到122
判断字符是数字还是大小写字母
int main() { input=getchar();//获取输入的字符 if(input <= 32) printf("You have input a control character!! "); else if(input >= 48 && input <= 57) //数字; { for( i=48;i<58;i++) { if(input==i) break; } printf("You put a number,ranging from 0--9! The number is %d! ",i); } else if(input >=65 && input <=90 ) //大写字母; { for( i=65; i<=90; i++) { if(input==i) break; } printf("You have put a uppercase! Ranging from A--Z! The number is %d! ",i); } else if(input >=97 && input <=122) //小写字母 { for( i=97;i<=122;i++) { if(i==input) break; } printf("You have input a lowercase! Ranging from a--z! The number is %d ",i); } else printf("You have input a other character! "); }