基础题(水题)
数组存对应字母
坑点在于结合题意判重
一个原字母对应两个加密字母不行
两个原字幕对应一个加密字母不行
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char mode[26];
memset(mode, '-', sizeof(mode));
string a, b, c;
cin>>a>>b>>c;
int lena = a.length(), lenc = c.length();
for(int i = 0; i < lena; i++)
{
if(mode[ a[i] - 'A' ] == '-')
{
mode[ a[i] - 'A' ] = b[i];
}
else
{
if(b[i] != mode[a[i] - 'A'])
goto l2;
}
}
for(int i = 0; i < 26; i++)
if(mode[i] == '-')
goto l2;
for(int i = 0; i < 26; i++)
{
int tms = 0;
for(int j = 0; j < 26; j++)
{
if(mode[j] == char('A' + i))
tms ++;
}
if(tms >= 2)
goto l2;
}
for(int i = 0; i < lenc; i++)
{
cout<<mode[c[i] - 'A'];
}
cout<<endl;
return 0;
l2:
cout<<"Failed"<<endl;
return 0;
}