Guest User

Untitled

a guest
Jan 16th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5. /*
  6. z .....
  7. 122
  8. 123
  9. 97
  10.  
  11. encryption
  12.  
  13. r -> n
  14. 114
  15.  
  16. 114 + 100 = 214
  17.  
  18. 214 - n * 26 = range a - z , a - 97 - 97 + 26
  19.  
  20. 114 + 100 - n * 26 = 110
  21. ?
  22.  
  23. y + 100 - n * 26 = 110
  24. ?
  25. ? sum of source arr[i] + 1
  26.  
  27. y = 110 - item2No + n * 26 -> a - z
  28. 110 - 100 = 10 + 26 * 4 = 114;
  29. 111 - (114 + 100) = -103 + 8 * 26 = 105;
  30.  
  31.  
  32. step 2
  33. step 1 ->
  34. 99 114 105 109 101
  35. 100 1 + 99 +114 1 + 99 + 114 + 105
  36. how to solve the value y?
  37.  
  38.  
  39. decrption:
  40. n -> r
  41.  
  42. 110 -> 114
  43. (char)(x)
  44. (int)c
  45. 97 + 'c' - 'a'
  46.  
  47. */
  48. string decrypt( const string& word )
  49. {
  50. // your code goes here
  51. int n = (int)word.size();
  52.  
  53. if (n < 1)
  54. return "";
  55.  
  56. int itemTwoNum = (int)word[0];
  57.  
  58. string result;
  59.  
  60. result += (char)(itemTwoNum - 1);
  61.  
  62. for (int i = 1; i < n; i++) {
  63. int stepTwoNum = (int)word[i] - itemTwoNum;
  64. while (stepTwoNum < 97 || stepTwoNum > 122) {
  65. stepTwoNum += 26;
  66. }
  67.  
  68. result += (char)stepTwoNum;
  69.  
  70. itemTwoNum += stepTwoNum;
  71. }
  72.  
  73. return result;
  74. }
  75.  
  76. int main() {
  77. return 0;
  78. }
Add Comment
Please, Sign In to add comment