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 102
|
#include <iostream>
#include <fstream>
#include <string>
enum cryptionType{ENCRYPTION, DECRYPTION};
void keywordFunction (ifstream& fin, string& encyc,string& word, string alpha, char arrizle[5][5]);
using namespace std;
const int MAX = 25;
int main()
{
char ch;
char letter;
int count = 0;
int doubleCount = 0;
int encycLength = 0;
int k = 0;
string encyc;
string word;
string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXY";
char arrizle[5][5];
cryptionType codeType;
ifstream fin;
ofstream fout;
fin.open("mp6encode2.txt");
fout.open("mp6output.txt");
if(!fin)
cout << "Input file did not open.";
keywordFunction (fin,encyc,word,alpha,arrizle);
fin.close();
fin.clear();
return 0;
}
void keywordFunction (ifstream& fin, string& encyc,string& word, string alpha, char arrizle[5][5]);
{
bool doesMatch = false;
getline(fin,word);
word += alpha;
cout << "word is " << word << endl;
encyc += word[0];
for(int counter = 1; counter < word.length(); counter++)
{
doesMatch = false;
for( int j = 0;j < counter - doubleCount; j++)
{
if(encyc[j ] == word[counter])
{
doesMatch = true;
doubleCount++;
}
}
if(!doesMatch)
{
encyc += word[counter];
encycLength++;
}
}
cout << "encyc is " << encyc << endl;
for(int i =0; i <5; i++)
{
for(int j=0; j<5; j++)
{
arrizle[i][j] = encyc[k++];
}
}
for(int i =0; i <5; i++)
{
for(int j=0; j<5; j++)
{
cout << arrizle[i][j] << " ";
}
cout << endl;
}
}
|