Question: Assignment: Square Matrix (Caesar Block)Cipher Arrange a stream in a two dimensional array of characters by filling up the array a line at a time,
Assignment: Square Matrix ("Caesar Block")Cipher Arrange a stream in a two dimensional array of characters by filling up the array a line at a time, from leftmost column to rightmost column. DO NOT USE A GETLINE: this program should be able to input an entire library, not a single line or word. Remember: we're building tools real people would use for real tasks. Remember, read, and use the "waterpump" design, that is why it was provided you. Then, to encypher the text, print out the array from top row to bottom row, leftmost column to rightmost colum. In Programmer Speak, we create a Row-Major character matrix, then print it as a Column-Major character matrix. Example: Here's a message: "meetmeinsaintlouis" It has 17 characters. We need a square array of char to hold it...but 17 isn't a square number. What's the next-largest square (bigger than 17?) 2 . 2 = 4 3 . 3 = 9 4 . 4 = 16 5 . 5 = 25 HAH! 25. (And what's the square root of 25? 5 ) So create char matrix[5][5] ; So write the message into a 5 x 5 square going left to right/top to bottom: meetm einsa intlo uisxx xxxxx (Note we padded out the extra cells with 'x'. In reality, we'd use random letters.) Print it out going top to bottom THEN left to right: STOP: BE SURE YOU UNDERSTAND THE PRECEEDING SENTENCE. CAN YOU SEE HOW TO DO IT IN YOUR MIND? If not, keep thinking about it. Here's the enciphered message: meiuxeinixentsxtslxxmaexx input: Karla: The young woman named Alexandra Borisovna Ostrakhova is your daughter. OUTPUT: KonasaoeqauanokurbrnmdvhrnhlgernodwcawdaavaldToABOaurahmlosigbreaertshbzynxirytmo Tools needed for this Assignment: std::string string::length() string::erase() string::[] If there is ANY EXTRANEOUS TEXT in the stream, (LIKE FROM EXTRA PROMPTS AND WARNINGS FROM YOUR PROGRAM) your code will only produce gibberish. We're here to build tools for serious workers to use. Please keep that goal uppermost in your mind, and never add anything unnecessary. Good machines are simple and solid. Build only good machines. Since we're desling with functions() in the text this week, let's break down the parts fo the program into functions: int side_length(int length) { // call side_length with the length of the message // it should return you an integer which is the // correct length of the square array of characters // to hold the message, plus any padding characters. } int randchar(void) { //return a random lower-case alphabetic character when called // note: (((rand() * some multiplier) % 26 )+ 'a') will produce such a character }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
