#include<stdio.h>
#include<stdlib.h>
int main(){
int ch = 0;
printf("輸入一個字元!\n");
while ((ch = getchar()) != 0){ //迴圈中ch均表示為ASCII值
if (ch >= "a"&&ch <= "z"){
printf("%c", ch - 32);
}
if (ch >= "A" && ch <= "Z"){
printf("%c", ch + 32);
if (ch >= "0"&&ch <= "9"){
printf("無效輸入!");
system("pause");
return 0;
#include<stdio.h>
#include<stdlib.h>
int main(){
int ch = 0;
printf("輸入一個字元!\n");
while ((ch = getchar()) != 0){ //迴圈中ch均表示為ASCII值
if (ch >= "a"&&ch <= "z"){
printf("%c", ch - 32);
}
if (ch >= "A" && ch <= "Z"){
printf("%c", ch + 32);
}
if (ch >= "0"&&ch <= "9"){
printf("無效輸入!");
}
}
system("pause");
return 0;
}