#include <stdio.h>
int main()
{char c;
printf("请输入:");
scanf("%c",&c);
if('a'<=c<='z')
printf("你输入的是小写字母");
else
if('A'<=c<='Z')
printf("你输入的是大写字母");
else
printf("你输入的不是字母");
return 0;
}
少了&& ,望采纳
#include <stdio.h>
int main()
{char c;
printf("请输入:");
scanf("%c",&c);
if('a'<=c&&c<='z')
printf("你输入的是小写字母");
else
if('A'<=c&&c<='Z')
printf("你输入的是大写字母");
else
printf("你输入的不是字母");
return 0;
}
顺序有问题,先判断是不是字母再判断大小写,而代码是先判断是不是大小写。
'a'<=c<='z'是不能作为判断条件的。应该为c>='a'&&c<='z'
1、改为如下方式就可以了
2、代码
#include <stdio.h>
int main()
{
char c;
printf("请输入:");
scanf("%c",&c);
if('a'<=c && c<='z')
printf("你输入的是小写字母");
else if('A'<=c && c<='Z')
printf("你输入的是大写字母");
else
printf("你输入的不是字母");
return 0;
}
改成如下形式 ,语法错误。if(c>='A'<&&c<='Z')
#include <stdio.h>
int main()
{char c;
printf("请输入:");
scanf("%c",&c);
if(c>='a'&&c<='z')
printf("你输入的是小写字母");
else
if(c>='A'<&&c<='Z')
printf("你输入的是大写字母");
else
printf("你输入的不是字母");
return 0;
}