Created
November 12, 2018 19:31
-
-
Save dertst/eae7a9a98b259465a789e49cbbec8742 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "pch.h" | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
int main() | |
{ | |
char key[5][5] = { 'v', 'e', 'r', 'o', 'n', | |
'i', 'c', 'a', 'b', 'd', | |
'f', 'g', 'h', 'k', 'l', | |
'm', 'p', 'q', 's', 't', | |
'u', 'w', 'x', 'y', 'z' }; | |
string letter; | |
getline(cin, letter); | |
int size = letter.length(); | |
int i = 0; | |
while (i < size) { | |
size = letter.length(); | |
if (letter[i] == ' ') { | |
letter.erase(i, 1); | |
} | |
letter[i] = tolower(letter[i]); | |
i = i++; | |
} | |
i = 0; | |
size = letter.length(); | |
while (i < size) { | |
if (letter[i] == letter[i + 1]) { | |
letter[i + 1] = 'x'; | |
} | |
i = i + 2; | |
} | |
int a = 0; | |
int b = 0; | |
int g = 0; | |
int j = 0; | |
i = 0; | |
while (g < 5) | |
{ | |
while (j < 5) | |
{ | |
if (key[g][j] == letter[i]) | |
{ | |
b = g; | |
} | |
if (key[g][j] == letter[i + 1]) | |
{ | |
a = g; | |
} | |
} | |
} | |
while (g < 5) | |
{ | |
while (j < 5) | |
{ | |
if (key[g][j] == letter[i]) | |
{ | |
key[g][j] = key[b][j]; | |
} | |
if (key[g][j] == letter[i + 1]) | |
{ | |
key[g][j] = key[a][j]; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment