编辑代码


#include <stdio.h>
#include <ctype.h>

int main(void) {
    char str[100];
    printf("请输入一个字符串:");
    fgets(str, 100, stdin);
    
    for(int i = 0; str[i] != '\0'; i++) {
        if(isupper(str[i])) {
            str[i] = tolower(str[i]);
        } else if(islower(str[i])) {
            str[i] = toupper(str[i]);
        }
    }
    
    printf("转换后的字符串为:%s", str);
    return 0;
}