I have a project assignment where I have to encrypt/decrypt a phrase using a Polybius Square.
I need to place the letters in a 2-d array (polybius square), and omit the duplicated letters. Once the phrase is in the table, fill out the rest of the table with the remaining letters of the alphabet. If anyone could check my code, and maybe give some advice, that would be awesome.
// This program was created to translate a group of letters into a sequence of numeric codes
// Comp 1108
// Created by:
// Last updated: 9/16/2013
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
usingnamespace std;
main()
{
string key, noRepeat;
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string table[5][5];
cout << "Please enter the key: ";
getline(cin, key);
cout << key << endl;
for(int i=0; i<key.length();i++)
{
key[i]=toupper(key[i]);
}
cout << key <<endl;
bool isLetter=false;
bool found=false;
for(int i=0;i<key.length();i++)
{
for(int j=0;j<noRepeat.length();j++)
{
if (key[i]==noRepeat[j])
found=true;
}
for(int k=0; k < alphabet.length(); k++)
{
if (key[i]==alphabet[k])
isLetter=true;
}
if (!found && isLetter)
noRepeat+=key[i];
found=false;
isLetter=false;
// need it to fill in rest of table with remaining alphabet
for(int t=0; t < noRepeat.length(); t++)
{
for (int m=0; m < alphabet.length(); m++)
{
if (noRepeat[t]==alphabet[m])
}
}
}
cout << noRepeat << endl;
system("PAUSE");
return 0;
}