题解 | #简单密码#

简单密码

http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac

#include<bits/stdc++.h>

using namespace std;

int main(void) { vector D; vector out; string temp; temp = "abcdefghijklmnopqrstuvwxyz"; for(int i = 0;i<8;i++) { if(i<=4) D.push_back(temp.substr(3i,3)); else if(i==5) D.push_back(temp.substr(3i,4)); else if(i==6) D.push_back(temp.substr(3i+1,3)); else if(i==7) D.push_back(temp.substr(3i+1)); }//D[0] - D[7] == 2-9 temp.clear(); while(cin>>temp) { string str; int size = temp.size(); for(int i=0;i<size;i++) { if(temp[i]>= '0' && temp[i]<= '9') { str = temp[i]; out.push_back(str); str.clear(); } if(temp[i]>= 'a' && temp[i]<= 'z') { for(int j =0;j<8;j++) if(D[j].find(temp[i]) != D[j].npos) { str = (j+2) + '0'; out.push_back(str); str.clear(); } } if(temp[i]>= 'A' && temp[i]< 'Z') { temp[i] += 33; str = temp[i]; out.push_back(str); str.clear(); } else if(temp[i] == 'Z') { temp[i] = 'a'; str = temp[i]; out.push_back(str); str.clear(); }

    }
    int siz = out.size();
    for(int i =0;i<siz;i++)
    {
        cout<<out[i];
    }
}

}

全部评论

相关推荐

零OFFER战士:另一个版本查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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