1 #include <stdio.h> 2 3 int main() 4 { 5 char ch; 6 printf("input characters:"); 7 ch = getchar(); 8 while (ch!='\n') 9 { 10 if (ch >= 'A' && ch <= 'Z') 11 { 12 ch = ch + ('a' - 'A'); //ascii编码位置 13 } 14 else 15 { 16 if (ch >= 'a' && ch <= 'z') 17 { 18 ch = ch - ('a' - 'A'); 19 } 20 } 21 putchar(ch); 22 ch = getchar(); 23 } 24 25 return 0; 26 }