显示代码纯文本
# include <bits/stdc++.h>
using namespace std;
char str[1003], st[103];
int num[103];
int main() {
freopen("vigenere.in", "r", stdin);
freopen("vigenere.out", "w", stdout);
scanf("%s%s", st, str);
int len = strlen(st);
int len2 = strlen(str);
for(int i = 0; i < len; i++) {
if(st[i] < 'a') num[i] = st[i] - 'A';
else num[i] = st[i] - 'a';
}
for(int i = 0; i < len2; i++) {
for(int j = 0; j < len && i < len2; j++, i++) {
if(str[i] >= 'a') {
str[i] -= num[j];
if(str[i] < 'a') str[i] += 26;
} else {
str[i] -= num[j];
if(str[i] < 'A') str[i] += 26;
}
putchar(str[i]);
}
i--;
}
}