fork(5) download
  1. /**********************************************
  2.  * *
  3.  * ADITYA KUMAR SINGH *
  4.  * (hangover) *
  5.  * 2nd YEAR *
  6.  * INDIAN INSTITUTE OF INFORMATION TECHNOLOGY *
  7.  * ALLAHABAD *
  8.  * *
  9.  **********************************************/
  10.  
  11. #include <bits/stdc++.h>
  12. #define ll long long int
  13. #define MOD 1000000007
  14.  
  15. using namespace std;
  16. char st[10000000], s[1000000];
  17.  
  18. int main(){
  19. cout << "Enter your Ceaser Chipher to decrypt:\n";
  20. cin >> s;
  21. ll t;
  22. t = strlen(s);
  23. ll n;
  24. strcpy(st,s);
  25. /*cout << "Shift of how many characters:\n";
  26.   cin >> n;*/
  27. cout << "Shift in which direction (r(right) or l(left)) :\n";
  28. char c;
  29. cin >> c;
  30. srand(time(NULL));
  31. n = (rand() % 25) + 1;
  32. cout << "Your String is shifted by:" << n <<endl;
  33. ll f;
  34. if(c=='r'){
  35. for(int i=0;i<strlen(st);i++){
  36. f = st[i] + n;
  37. if(f>122)
  38. f = f - 26;
  39. st[i] = f;
  40. }
  41. }
  42. else if(c=='l'){
  43. for(int i=0;i<strlen(st);i++){
  44. f = st[i] - n;
  45. if(f<97)
  46. f = f + 26;
  47. st[i] = f;
  48. }
  49. }
  50. cout <<"Your encrypted String :-> "<< st <<endl;
  51. return 0;
  52. }
  53.  
Success #stdin #stdout 0s 13840KB
stdin
aditya
r
stdout
Enter your Ceaser Chipher to decrypt:
Shift in which direction (r(right) or l(left)) :
Your String is shifted by:24
Your encrypted String :-> ybgrwy