解题思路:
注意事项:
参考代码:
#include<bits/stdc++.h>
using namespace std;
string s ="abcdefghijklmnopqrstuvwxyz";
char a[30][30];
string s1,s2;
int main()
{
int la,lb,ans;
for(int i = 0 ; i < 26 ;i++)
for(int j = 0 ; j < 26 ;j++)
{
int k = (i+j) % 26;
a[i][j] = s[k];
}
cin >> s1 >> s2;
for(int i = s1.size(),j = 0 ; i <= s2.size() ;i++,j++)
s1[i] = s1[j];
for(int i = 0 ; i <= s2.size() ;i++)
{
ans = 0;
if(s2[i] >= 'A' && s2[i] <= 'Z')
{
s2[i] = s2[i] + 32;
ans++;
}
if(s1[i] >= 'A' && s1[i] <= 'Z')
{
s1[i] = s1[i] + 32;
ans++;
}
for(int k = 0 ; k < 26 ;k++)
{
if(s1[i] == s[k])
{
la = k;
break;
}
}
for(int j = 0 ; j < 26 ;j++)
{
if(a[la][j] ==s2[i])
{
if(ans == 2)
cout << char(s[j]-32);
else cout << s[j];
break;
}
}
}
return 0;
}
0.0分
0 人评分