fork download
  1. #include <stdio.h>
  2. #define MAX_CHAR 100
  3. int main(void) {
  4. char str[MAX_CHAR+1];
  5. int i;
  6.  
  7. printf("文字列を入力してください: ");
  8. scanf("%s", str);
  9.  
  10. for (i = 0; str[i] != '\0'; i++) {
  11. if (str[i] >= 'a' && str[i] <= 'z') {
  12. str[i] = str[i] - 'a' + 'A';
  13. }
  14. else if (str[i] >= 'A' && str[i] <= 'Z') {
  15. str[i] = str[i] - 'A' + 'a';
  16. }
  17. }
  18.  
  19. printf("変換した文字列: %s\n", str);
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 5292KB
stdin
poiuA
stdout
文字列を入力してください: 変換した文字列: POIUa