|
- #include<iostream>
- #include<map>
- using namespace std;
- string s1="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- string s2="abcdefghijklmnopqrstuvwxyz";
- map<char,int>M,m;
- string key,mi,c;
- int im,ik;
- int main()
- {
- cin>>key>>mi;
- for(int i=0;i<26;i++)
- M.insert(make_pair(char(i+'A'),i)),
- m.insert(make_pair(char(i+'a'),i));
- while(im<mi.size())
- {
- int k;
- if(mi[im]>='a'&&mi[im]<='z')k=mi[im]-'a';
- else k=mi[im]-'A';
- if(key[ik]>='a'&&key[ik]<='z')k-=m[key[ik]];
- else k-=M[key[ik]];
- k=(k+26)%26;
- if(mi[im]>='a'&&mi[im]<='z')cout<<s2[k];
- else cout<<s1[k];
- im++,ik++;
- ik%=key.size();
- }
- return 0;
- }
复制代码 |
|