方法1:
#include
#include
//大小写字母隔了32位
void main(){
char ch,t;
printf("Please input a letter:\n");
ch=getchar();
t=getchar(); //吸收回车键
while((ch'z') || (ch'a')){
printf("Input error!\nPlease input again:\n");
ch=getchar();
}
if(ch & )
ch=ch & ; //使第五位为0,变大写
else ch=ch | ; //使第五位为1,变小写
putchar(ch);
printf("\n");
}
方法2:
#include
#include
//大小写字母隔了32位
void main(){
char ch;
printf("Please input a letter:\n");
scanf("%c",&ch);
ch=(ch>='A' && ch<='Z')?(ch+):((ch>='a' && ch<='z')?(ch-):printf("Input error!"));
printf("%c\n",ch);
}
结果为: