-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP1079.cpp
36 lines (36 loc) · 935 Bytes
/
P1079.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[110],b[1010];
bool caps=false;
int main(){
cin>>a;
cin>>b;
int pos=0;
for(int i=0;i<strlen(b);i++){
char cur_key=a[pos];
char cur_pass=b[i];
pos++;
if(pos>=strlen(a)) pos=0;
if(cur_pass-'a'>=0) caps=false;
else caps=true;
int cur_passn,cur_keyn;
if(caps==true) cur_passn=cur_pass-'A';
else cur_passn=cur_pass-'a';
if(cur_key>='a') cur_keyn=cur_key-'a';
else cur_keyn=cur_key-'A';
if(cur_passn>=cur_keyn){
char ans=cur_passn-cur_keyn;
if(caps==true) printf("%c",ans+'A');
else printf("%c",ans+'a');
}
else{
char ans=(26-cur_keyn)+cur_passn;
if(caps==true) printf("%c",ans+'A');
else printf("%c",ans+'a');
}
}
printf("\n");
return 0;
}