Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <cmath>
- #include <string>
- using namespace std;
- int main(){
- ifstream in("desifravimas-vyr.in");
- ofstream out("desifravimas-vyr.out");
- int N,K;
- char x;
- in>>N; //1
- char A[N]={ },B[N]={ };
- for(int i=0;i<N;i++) //2n
- {
- in>>x;
- A[i]=x;
- }
- for(int i=0;i<N;i++) //2n
- {
- in>>x;
- B[i]=x;
- }
- int o=0;
- while(A[o]==B[o]) //n
- o++;
- K=int(A[o])-int(B[o]);
- for(int i=0;i<N;i++) //7n^3
- { //↖↖
- if(int(B[i])>64&&int(B[i])<91) //3n^2
- { //↖↖
- if(int(B[i])+K>90) //n
- out<<char(int(B[i])+K-26);
- else if(int(B[i])+K<65) //n
- out<<char(int(B[i])+K+26);
- else //n
- out<<char(int(B[i])+K);
- }
- else if(int(B[i])>96&&int(B[i])<123)
- {
- if(int(B[i])+K>122)
- out<<char(int(B[i])+K-26);
- else if(int(B[i])+K<97)
- out<<char(int(B[i])+K+26);
- else
- out<<char(int(B[i])+K);
- }
- else
- out<<B[i];
- }
- return 0;
- }
- //is viso 7n^3+5n+1
Add Comment
Please, Sign In to add comment