本题要求编写程序,将给定字符串中的大写英文字母按以下对应规则替换:

输入格式:

输入在一行中给出一个不超过80个字符、并以回车结束的字符串。

输出格式:

输出在一行中给出替换完成后的字符串。

输入样例:

Only the 11 CAPItaL LeTtERS are replaced.

输出样例:

Lnly the 11 XZKRtaO OeGtVIH are replaced.
#include <stdio.h>
#include <string.h>
int main(int argc, char const *argv[])
{
    char str[81] = {0};
    char *p = str;
    gets(str);
    int len = strlen(str);
    if(len>0 && len<=80)
    {
        while(*p != '\0')
        {
            if(*p>='A' && *p<='Z')
                *p = 'A' + 'Z' - *p;
            p++;
        }
        puts(str);
    }
    return 0;
}
Last modification:2021 年 03 月 27 日 16 : 36 : 55