Question
This is the code I was able to come up with, so far: /* * File: main.cpp * Author: carlosblanco *https://code.sololearn.com/cKAqC9car7Xx#java * https://stackoverflow.com/questions/26941470/initializing-2d-char-array-in-c * https://www.quora.com/Is-it-a-good-practice-to-declare-the-counter-inside-a-loop-or-outside-My-professor-says-it-is-much-better-practice-to-declare-all-variables-at-the-beginning-of-a-block-is-this-true
This is the code I was able to come up with, so far:
/* * File: main.cpp * Author: carlosblanco *https://code.sololearn.com/cKAqC9car7Xx#java * https://stackoverflow.com/questions/26941470/initializing-2d-char-array-in-c * https://www.quora.com/Is-it-a-good-practice-to-declare-the-counter-inside-a-loop-or-outside-My-professor-says-it-is-much-better-practice-to-declare-all-variables-at-the-beginning-of-a-block-is-this-true * Created on September 16, 2018, 11:51 AM */
#include
using namespace std;
/* * */ int main(int argc, char** argv) {
char square[5][5];
square[0][0] = 'c'; square[0][1] = 'r'; square[0][2] = 'a'; square[0][3] = 'z'; square[0][4] = 'y'; square[1][0] = 'b'; square[1][1] = 'd'; square[1][2] = 'e'; square[1][3] = 'f'; square[1][4] = 'g'; square[2][0] = 'h'; square[2][1] = 'i'; square[2][2] = 'j'; square[2][3] = 'k'; square[2][4] = 'l'; square[3][0] = 'm'; square[3][1] = 'n'; square[3][2] = 'o'; square[3][3] = 'p'; square[3][4] = 's'; square[4][0] = 't'; square[4][1] = 'u'; square[4][2] = 'v'; square[4][3] = 'w'; square[4][4] = 'x';
char * size = sizeof (square);
char input[26]; fgets(input, 26, stdin);
while (input != NULL) {
for (int i = 0; i
int j = 0; for (j = 0; j
int k = 0; for (k = 0; k
if (b == square[j][k]) { int firstLetter = j + 1; int secondLetter = k + 1;
printf("%d + ", secondLetter); }
}
}
}
}
return 0; }
prorpts git eornitage deacribing this cemit' . In the decryptioa program, you mAyassane the inpt will eonsist of the digits o-4. The program will print the decrypted message. You'll be usig the antoratie grading ript, yon't med to pprint. teeminal vsing geta. The Polybius Square Cipher This cipher,named after the ancient Greek scholar Polybius, ases a spcial key square to substitate letters from the plaintext with aumerie oles The cottets of Ille uare are 20 ltters of the alphabet arranged in some closo permutatlon. For example, Hevien the notes on strigs sd uidimensioal says that are included with this prolect. The notes on strings aso inelude Information about reading string input from a user 01 2 3 4 0lcrazy anples. int digit--0 Te omitted letter may be one that is inrnty , like zor he leter j may be emitted and eplaced by i anywhee it occs in the plaintext. In the example ahove, the square has heen generated using the ryward crazy To encipber a messapp, locate its eutry in theuatrix, then replace it with the two-dlgit coibination formed from the row index and the col dex. For example, the letter n woald beenanded as 31 becasitis in 3 and comn1 Here isexape 024040020023024011024331 To decrypt the message. simplywe each pair of cusesecutive digits as a row And coluan lookup into the square. Write two cu, polybiusFncrypt.cand polybiuaDacrypt.e that ipl- ment the phr Use the example suware given abore both programs. You doa't need to write code to generate other squares Each peogram should read a string from the wer using fgets. Reembur that the hat dharacter of the input will be a ewline In the ectypion program, you may e the put string will be co- will print the eneryptind string. The ecryption input way coutain the lette qz alloe letters
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started