蒟蒻求助 555
查看原帖
蒟蒻求助 555
335094
Lucifero楼主2020/5/22 21:52
#include <bits/stdc++.h>
using namespace std;
int k;
string s1,s2;
int main()
{
	//Vigenère 密码
	int l1,l2,i;
	cin>>s1>>s2;
	l1=s1.length(),l2=s2.length();
	for(i=0;i<l1;i++)
		if (s1[i]<'z' && s1[i]>'a') s1[i]-='a'-'A';
	for(i=0;i<l2;i++)
	{
		s2[i]-=s1[k]-'A';k++;
		if (s2[i]<='Z' && s2[i]<'A') s2[i]+='Z'-'A'+1;
		else if (s2[i]<'a') s2[i]+='z'-'a'+1;
		if (k>l1-1) k=0;
	}
	cout<<s2;
}
2020/5/22 21:52
加载中...