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
|
#include "pch.h"
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
char alphabet[] =
{ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
int i, k;
char alph_cipher[25];
for (i = 0; i <= 25; i++) {
k = (i + 3) % 26;
alph_cipher[i] = alphabet[k];
}
string str;
cout << "enter a word" << endl;
getline(cin, str);
cout << "the encryption of the word is" << endl << endl;
int string_length = str.size();
for (i = 0; i <= (string_length - 1); i++)
{
for (k = 0; k <= 25; k++)
{
if (str[i] == alphabet[k])
{
cout << alph_cipher[k];
}
}
}
return 0;
}
|