首页 > 试题广场 >

字符串的反码

[编程题]字符串的反码
  • 热度指数:6218 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
    一个二进制数,将其每一位取反,称之为这个数的反码。下面我们定义一个字符的反码。如果这是一个小写字符,则它和字符'a’的距离与它的反码和字符'z’的距离相同;如果是一个大写字符,则它和字符'A’的距离与它的反码和字符'Z’的距离相同;如果不是上面两种情况,它的反码就是它自身。     举几个例子,'a’的反码是'z’;'c’的反码是'x’;'W’的反码是'D’;'1’的反码还是'1’;'$'的反码还是'$'。     一个字符串的反码定义为其所有字符的反码。我们的任务就是计算出给定字符串的反码。

输入描述:
    输入是一个字符串,字符串长度不超过 80 个字符。


输出描述:
输出其反码
示例1

输入

Hello

输出

Svool
示例2

输入

JLU-CCST-2011 

输出

QOF-XXHG-2011
头像 用户抉择
发表于 2021-03-29 20:49:32
#include <stdio.h> #include <string.h> int main(){     char s[80];     int&nbs 展开全文
头像 MrMello
发表于 2023-03-17 13:26:40
#include <stdio.h> #include <string.h> int main(){ char text[81] = {0}; gets(text); int len = strlen(text); char reverse[l 展开全文
头像 小徐小徐啊啊
发表于 2024-03-10 21:45:23
#include <stdio.h> #include <string.h> int main() { char a[80],f[80]; scanf("%s",&a); for(int i=0;i<strlen(a);i++) { 展开全文
头像 在考古的小鱼干很有气魄
发表于 2023-03-11 11:52:19
#include <bits/stdc++.h> #define MAX 81 using namespace std; int main(){ int len; char s[MAX]; while(cin>>s){ char res[MAX]; for(i 展开全文
头像 牛客440904392号
发表于 2024-10-01 01:59:17
s = input() for c in s: if c.isalpha(): if c.isupper(): print(chr(ord("A") + 25 - (ord(c) - ord("A"))), en 展开全文
头像 阿尔芒a
发表于 2024-03-20 19:34:23
#include<iostream> #include<string> #include<algorithm> using namespace std; int main() { string str; while (cin >> 展开全文
头像 牛客242505259号
发表于 2023-03-12 11:45:00
#include <iostream> #include <string> using namespace std; int main() { string str; cin>>str; for(int i = 0;i < str. 展开全文
头像 haley06
发表于 2023-09-26 01:13:48
#include <stdio.h> #define N 100 int main() { char arr[N]; scanf("%s",arr); int i=0; while(arr[i]!='\0'){ if(arr[i]> 展开全文
头像 牛客127952153号
发表于 2023-01-11 10:26:08
#include<iostream> using namespace std; int main() { string s; while(cin >> s) { for(int i = 0; i < s.length(); i++ 展开全文
头像 笑川不吃香菜
发表于 2024-03-20 09:41:16
#include <cctype> #include <iostream> using namespace std; int main() { string s;cin>>s; for(int i =0;i<s.length();i++){ 展开全文