显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <set>
#include <deque>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <sstream>
#include <vector>
#include <ctime>
using namespace std;
const int maxn=10000+10;
const int maxm=1000+10;
char s1[maxm],s2[maxn];
char pan[maxn];
char s4[maxn],s5[maxn];
int len2,len1;
int p=0,q=0;
int main()
{
freopen("vigenere.in","r",stdin);
freopen("vigenere.out","w",stdout);
gets(s1); gets(s2);
strcpy(s5,s2);
len1=strlen(s1); len2=strlen(s2);
while(q<=len2)
{
if(s1[p]>='a' && s1[p]<='z')
{
s1[p]=s1[p]-32;
}
if(s2[q]>='a' && s2[q]<='z')
{
s2[q]=s2[q]-32;
}
if(s2[q]-65>=s1[p]-65)
{
pan[q]=(s2[q]-65-(s1[p]-65))+65;
}
else
{
pan[q]=90-(s1[p]-65-(s2[q]-65))+1;
}
p++;
q++;
if(p==len1)
{
p=0;
}
}
for(int i=0;i<len2;i++)
{
pan[i]=pan[i]+32;
if(s5[i]>=65 && s5[i]<=90)
{
pan[i]=pan[i]-32;
}
cout<<pan[i];
}
return 0;
}