|
发表于 2020-2-28 12:20:08
|
显示全部楼层
#include<stdio.h>
void main()
{
char c;
printf("input a character:\n");
c=getchar();
if(c<32)
{
printf("this is a control character\n"); //输入值小于32的,显示this is a control character
}
else if(c>='0'&&c<='9')
{
printf("this is a digital\n"); //输入0到9数字,显示this is a digital
}
else if(c>='A'&&c<='Z')
{
printf("this is a capital letter\n"); //输入A到Z数字,显示this is a capital letter
}
else if(c>='a'&&c<='z')
{
printf("this is a small letter\n"); //输入a 到z数字,显示this is a small letter
}
else
{
printf("this is a other character\n"); //其它的,显示this is a other character
}
}
当你输入不同类型的符号,会输出不同的语句,输入数字都是显示一样的语句。 |
|