fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. char x, y;
  5. printf("请输入两个字符(a-z 或 A-Z):");
  6. scanf(" %c %c", &x, &y);
  7.  
  8. if (x >= 'a' && x <= 'z')
  9. x = x - 32; // 小写转大写
  10. else
  11. x = x + 32; // 大写转小写
  12.  
  13. if (y >= 'a' && y <= 'z')
  14. y = y - 32;
  15. else
  16. y = y + 32;
  17.  
  18. printf("转换后的字符为:%c %c\n", x, y);
  19. return 0;
  20. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
请输入两个字符(a-z 或 A-Z):转换后的字符为: