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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
#include <iostream>
#include <string>
#include <cctype>
#include <sstream>
using namespace std;
int main()
{
string A, E, I, O, U, a, e, i, o, u, line;
cout << "Enter a line to encrypt" << endl;
cin >> line;
string b = line;
//vowels
int loc;
do{
loc = line.find("a");
if (loc != -1)
line = line.replace(loc, 1, "1");
} while (loc != -1);
do{
loc = line.find("A");
if (loc != -1)
line = line.replace(loc, 1, "1");
} while (loc != -1);
do{
loc = line.find("e");
if (loc != -1)
line = line.replace(loc, 1, "2");
} while (loc != -1);
do{
loc = line.find("E");
if (loc != -1)
line = line.replace(loc, 1, "2");
} while (loc != -1);
do{
loc = line.find("i");
if (loc != -1)
line = line.replace(loc, 1, "3");
} while (loc != -1);
do{
loc = line.find("I");
if (loc != -1)
line = line.replace(loc, 1, "3");
} while (loc != -1);
do{
loc = line.find("o");
if (loc != -1)
line = line.replace(loc, 1, "4");
} while (loc != -1);
do{
loc = line.find("O");
if (loc != -1)
line = line.replace(loc, 1, "4");
} while (loc != -1);
do{
loc = line.find("u");
if (loc != -1)
line = line.replace(loc, 1, "5");
} while (loc != -1);
do{
loc = line.find("U");
if (loc != -1)
line = line.replace(loc, 1, "5");
} while (loc != -1);
// Other
int len, r, y = 0, x = 0;
len = line.length();
for (int i = 0; i < len; i++)
{
r = (int)b[i];
y = r + 3;
line = line.replace(i, 1, y);
}
cout << line << endl;
system("pause");
return 0;
}
|