mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-07 18:06:58 +08:00
Add FZOI Codes
This commit is contained in:
20
FZOI/「NOIP2012」Vigenère 密码.cpp
Normal file
20
FZOI/「NOIP2012」Vigenère 密码.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
int k = -1;
|
||||
string a, b;
|
||||
int main(){
|
||||
cin >> b >> a;
|
||||
int lena = a.length(), lenb = b.length();
|
||||
for(int i = 0; i < lena; i ++ ){
|
||||
++ k;
|
||||
if(k == lenb) k -= lenb;
|
||||
char c = tolower(a[i]), d = tolower(b[k]);
|
||||
int x = (c - 'a') - (d - 'a');
|
||||
if(x < 0) x += 26;
|
||||
x ++ ;
|
||||
if(a[i] >= 'a' && a[i] <= 'z') printf("%c", x + 'a' - 1);
|
||||
else printf("%c", x + 'A' - 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user