题解 | #字符串的反码#

字符串的反码

https://www.nowcoder.com/practice/01b7dae14d1b464db5f9259e90d9a35e

#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

int main() {
    string str;
    cin>>str;
    for(int i=0;i<str.size();i++){
        if('A'<=str[i] && str[i]<= 'Z'){
            str[i]='A'+(25-(str[i]-'A'));
        }else if('a'<=str[i] && str[i]<= 'z'){
            str[i]='a'+(25-(str[i]-'a'));
        }
    }
    cout<<str<<endl;
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

缒梦&独舞:这家公司是这样的,去年给我实习offer了,不过也是面着玩儿的,他周六还要去做公益志愿活动
点赞 评论 收藏
分享
看到这个内容真是闹麻了。。。。。。现在有了AI以后很多人面试都会作弊吗?&nbsp;那对老老实实面试的人岂不是不公平....
程序员牛肉:公平那是对小孩子讲的童话故事,成年人的世界只有能不能接受失败的后果。 你要是能接受面试作弊被发现之后多家公司联合永久拉黑的后果,你就搞。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务