#include "stdafx.h"
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string s1,s2;
cin>>s1>>s2;
int len1=s1.length();
int len2=s2.length();
int a[256]={0};
char b[26]={0},j=0;
for (int i=0;i<len1;i++)
{
a[s1[i]]++;
if (a[s1[i]]==1)
{
b[j++]=s1[i];
}
}
b[j]='\0';
transform(s1.begin(),s1.end(),s1.begin(),tolower);
char bs[100]={0};int k=0;
for (char c='a';c<='z';c++)
{
for (int i=0;i<j;i++)
{
if (c!=b[i])
{
if(i==j-1)
bs[k++]=c;
}
else
{
break;
}
}
}
bs[k]='\0';
char Z[256]={0},x=0,y=0;
for (char c='a';c<='z';c++)
{
if (x<j)
{
Z[c]=b[x++];
}else
{
Z[c]=bs[y++];
}
}
for (int i=0;i<len2;i++)
{
cout<<Z[s2[i]];
}
cout<<endl;
return 0;
}
字符串加密
最新推荐文章于 2024-05-26 11:46:29 发布