forked from Innovators-Quest-VITVellore/GitHub-Task
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolution1
38 lines (37 loc) · 823 Bytes
/
solution1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//Code for question 1
#include <iostream>
#include <string>
using namespace std;
int main()
{
string word;
string final = "";
char temp;
int key;
int shift;
int i, j;
cout << "Enter the word " << endl;
cin >> word;
cout << "Enter the key " << endl;
cin >> key;
cout << "Enter the shift " << endl;
cin >> shift;
for (i = 0; i < word.length(); i++)
{
word[i] = word[i] + key;
}
cout << "After encrypting \n"
<< word << endl;
for (i = 0; i < shift; i++)
{
for (j = word.length() - 1; j > 0; j--)
{
temp = word[j];
word[j] = word[j - 1];
word[j - 1] = temp;
}
}
cout << "After shifting \n"
<< word << endl;
return 0;
}