123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
#include <iostream> #include <cmath> #include <string> #include <fstream> #include <vector> using namespace std; class functions { public: char alphabet[26]; int counter=0; string sentance; void input () { cout << endl; cout << "Write a sentence: "; getline(cin,sentance); } void subCipher () { cout << endl << "The new version is "; for (int i=0;i<sentance.length();i++) { if (sentance[i]==' ') { cout << " "; } for (int j=0;j<26;j++) { if (alphabet[j]==alphabet[23] && sentance[i]==alphabet[23]) { cout << alphabet[0]; } else if (alphabet[j]==alphabet[24] && sentance[i]==alphabet[24]) { cout << alphabet[1]; } else if (alphabet[j]==alphabet[25] && sentance[i]==alphabet[25]) { cout << alphabet[2]; } else if (alphabet[j]==sentance[i]) { cout << alphabet[j+3]; } } } cout << endl << endl; } void multiArrayCipher() { vector <char> multiArrayOne; vector <char> multiArrayTwo; vector <char> multiArrayThree; vector <char> multiArrayFour; for (int j=0;j<sentance.length();j+=4) { multiArrayOne.push_back(1); multiArrayOne(counter)=sentance[j]; counter++; } counter=0; for (int j=1;j<sentance.length();j+=4) { multiArrayTwo.push_back(1); multiArrayTwo(counter)=sentance[j]; counter++; } counter=0; for (int j=2;j<sentance.length();j+=4) { multiArrayThree.push_back(1); multiArrayThree(counter)=sentance[j]; counter++; } counter=0; for (int j=3;j<sentance.length();j+=4) { multiArrayFour.push_back(1); multiArrayFour(counter)=sentance[j]; counter++; } cout << endl << endl; } }; int main() { functions program; int input; ifstream file; file.open("alphabet.txt"); for (int j=0; j<26;j++) { file >> program.alphabet[j]; } while (input!=5) { cout << "1. Substitution cipher" << endl; cout << "2. Multi-array cipher" << endl; cout << "3. Transposition cipher" << endl; cout << "4. Code breaker" << endl; cout << "5. Exit" << endl << endl; cout << "Enter the number of the option you want to proceed with: "; cin >> input; cin.ignore(); switch (input) { case 1: program.input(); program.subCipher(); break; case 2: program.input(); program.multiArrayCipher(); } } return 0; }
multiArrayOne(counter)
multiArrayOne[counter]