输入字符,如果是大写则转化为小写,如果是小写则转化为大写
#include<stdio.h>
int main(){
char ch;
printf("Please enter letters:");
ch = getchar();
if(ch >= 'A' && ch <= 'Z'){
ch = ch +32;
}
else if(ch >= 'a' && ch <= 'z'){
ch = ch - 32;
}
printf("%c, %d\n",ch,ch);
}
输入字符,如果是大写则转化为小写,如果是小写则转化为大写
#include<stdio.h>
int main(){
char ch;
printf("Please enter letters:");
ch = getchar();
if(ch >= 'A' && ch <= 'Z'){
ch = ch +32;
}
else if(ch >= 'a' && ch <= 'z'){
ch = ch - 32;
}
printf("%c, %d\n",ch,ch);
}