Guest User

Untitled

a guest
Dec 11th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. #include <cmath>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. int main(){
  10. ifstream in("desifravimas-vyr.in");
  11. ofstream out("desifravimas-vyr.out");
  12. int N,K;
  13. char x;
  14. in>>N; //1
  15. char A[N]={ },B[N]={ };
  16. for(int i=0;i<N;i++) //2n
  17. {
  18. in>>x;
  19. A[i]=x;
  20. }
  21. for(int i=0;i<N;i++) //2n
  22. {
  23. in>>x;
  24. B[i]=x;
  25. }
  26. int o=0;
  27. while(A[o]==B[o]) //n
  28. o++;
  29. K=int(A[o])-int(B[o]);
  30. for(int i=0;i<N;i++) //7n^3
  31. { //↖↖
  32. if(int(B[i])>64&&int(B[i])<91) //3n^2
  33. { //↖↖
  34. if(int(B[i])+K>90) //n
  35. out<<char(int(B[i])+K-26);
  36. else if(int(B[i])+K<65) //n
  37. out<<char(int(B[i])+K+26);
  38. else //n
  39. out<<char(int(B[i])+K);
  40. }
  41. else if(int(B[i])>96&&int(B[i])<123)
  42. {
  43. if(int(B[i])+K>122)
  44. out<<char(int(B[i])+K-26);
  45. else if(int(B[i])+K<97)
  46. out<<char(int(B[i])+K+26);
  47. else
  48. out<<char(int(B[i])+K);
  49. }
  50. else
  51. out<<B[i];
  52. }
  53. return 0;
  54. }
  55.  
  56. //is viso 7n^3+5n+1
Add Comment
Please, Sign In to add comment