P1079 Vigenère 密码 题目
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<ctime>
#include<queue>
#include<stack>
#define rg register
#define lst long long
#define N 1050
using namespace std;
int lmy,lmw,now=-1;
char my[N],mw[N],ans[N];
inline int read()
{
rg int s=0,m=1;rg char ch=getchar();
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')m=-1,ch=getchar();
while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
return s*m;
}
int main()
{
cin>>my>>mw;
// puts(my),puts(mw);
lmy=strlen(my),lmw=strlen(mw);
// cout<<lmy<<" "<<lmw<<endl;
for(rg int i=0;i<lmy;++i)
if(my[i]>='a'&&my[i]<='z')my[i]-=32;
// puts(my);
for(rg int i=0;i<lmw;++i)
{
now++;
if(now==lmy)now=0;
ans[i]=mw[i]-my[now]+'A';
if(ans[i]<'a'&&(mw[i]>='a'&&mw[i]<='z'))ans[i]=mw[i]-my[now]+'A'+26;
if(ans[i]<'A'&&(mw[i]>='A'&&mw[i]<='Z'))ans[i]=mw[i]-my[now]+'A'+26;
}
puts(ans);
return 0;
}