付费资源下载站源码/宁波关键词优化排名工具
本题要求编写程序,将给定字符串中的大写英文字母按以下对应规则替换:
原字母 | 对应字母 |
---|---|
A | Z |
B | Y |
C | X |
D | W |
… | … |
X | C |
Y | B |
Z | A |
输入格式:
输入在一行中给出一个不超过80个字符、并以回车结束的字符串。
输出格式:
输出在一行中给出替换完成后的字符串。
输入样例:
Only the 11 CAPItaL LeTtERS are replaced.
结尾无空行
输出样例:
Lnly the 11 XZKRtaO OeGtVIH are replaced.
结尾无空行
//也可以通过ASCII码进行解答(左右两边加起来均为155)
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAXS 81
int main(void)
{char temp [MAXS];char ch;int i = 0;while ((ch =getchar()) != '\n') temp[i++] = ch;temp[i] = '\0';i = 0;while (temp[i] != '\0'){if (isupper(temp[i])){printf("%c", temp[i] + (25 - 2 * (temp[i]-'A')));}else printf("%c", temp[i]);i++;}printf("\n");return 0;
}