题解 | #字符串加密#

字符串加密

http://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3

简单的字符串操作即可

#include <bits/stdc++.h>
using namespace std;
int main(){
    string str,key;
    while(cin>>str>>key){
         string table="";
        for(int i=0;i<str.size();i++){
            if(table.find(str[i])==table.npos){
                table.push_back(str[i]);
            }
        }
        string a="abcdefghijklmnopqrstuvwxyz";
        for(int i=0;i<a.size();i++){
            if(table.find(a[i])==table.npos){
                table.push_back(a[i]);
            }
        }
        string result="";
        for(int i=0;i<key.size();i++){
            int index=key[i]-'a';
            result.push_back(table[index]);
        }
        cout<<result<<endl;
    }
   
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-11 11:29
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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