Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- /*
- z .....
- 122
- 123
- 97
- encryption
- r -> n
- 114
- 114 + 100 = 214
- 214 - n * 26 = range a - z , a - 97 - 97 + 26
- 114 + 100 - n * 26 = 110
- ?
- y + 100 - n * 26 = 110
- ?
- ? sum of source arr[i] + 1
- y = 110 - item2No + n * 26 -> a - z
- 110 - 100 = 10 + 26 * 4 = 114;
- 111 - (114 + 100) = -103 + 8 * 26 = 105;
- step 2
- step 1 ->
- 99 114 105 109 101
- 100 1 + 99 +114 1 + 99 + 114 + 105
- how to solve the value y?
- decrption:
- n -> r
- 110 -> 114
- (char)(x)
- (int)c
- 97 + 'c' - 'a'
- */
- string decrypt( const string& word )
- {
- // your code goes here
- int n = (int)word.size();
- if (n < 1)
- return "";
- int itemTwoNum = (int)word[0];
- string result;
- result += (char)(itemTwoNum - 1);
- for (int i = 1; i < n; i++) {
- int stepTwoNum = (int)word[i] - itemTwoNum;
- while (stepTwoNum < 97 || stepTwoNum > 122) {
- stepTwoNum += 26;
- }
- result += (char)stepTwoNum;
- itemTwoNum += stepTwoNum;
- }
- return result;
- }
- int main() {
- return 0;
- }
Add Comment
Please, Sign In to add comment