题解 | 字符串的反码

字符串的反码

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

//KY171 字符串的反码
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
string s;
int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]>='a'&&s[i]<='z'){
            s[i]=26-(s[i]-'a')-1+'a';
        }
        else if(s[i]>='A'&&s[i]<='Z'){
            s[i]=26-(s[i]-'A')-1+'A';
        }
    }
    cout<<s<<"\n";
    return 0;
}

全部评论

相关推荐

肥肠椒绿:双非本可不就犯天条了,双非本就应该打入无间地狱
点赞 评论 收藏
分享
03-31 21:47
东南大学 C++
彭于晏前来求offe...:吓晕了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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