Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program Description: =================== Given a 2D character array, called scrambled, filled with ad hoc characters, this program uses the [row, col] pair values stored in

Program Description: =================== Given a 2D character array, called "scrambled", filled with ad hoc characters, this program uses the [row, col] pair values stored in the 2D integer array, called "key", to retrieve characters from the "scrambled" array. The retrieved individual characters are concatenated, left to right, and in the order that they are retrieved, to form the complete decoded message. The message is then output. ------------------------------------------------------------------------------------------ */ #include  #include  #include  //===================== GLOBAL MACRO DEFINITIONS ========================================================== #define cNUL '\0' // NULL character #define sNUL "\0" // NULL String #define cBlank ' ' // Blank character #define sBlank " " // Blank String #define cUScore '_' // Underscore character #define sUScore "_" // Underscore string. // Define machine-independent TRUE and FALSE values #ifdef TRUE #undef TRUE #undef FALSE #endif #define TRUE (1==1) #define FALSE (0==1) // ======================== Statement Function Definitions. #define F_MIN(v1,v2) (((v1) < (v2))? (v1):(v2)) // Return the less of v1 and v2 #define F_MAX(v1,v2) (((v1) > (v2))? (v1):(v2)) // Return the greater of v1 and v2 #define ZF_MIN(v1,v2) (F_MAX(0, (F_MIN((v1),(v2))))) // Like F_MIN, but lower bounds the result at ZERO #define ZF(v) (F_MAX(0, (v))) // Lower bounds the value "v" at ZERO. #define F_NOT(v) (((v) == TRUE)? FALSE:TRUE) // Logical Negation. #define F_ABS(v) (((v) >= 0 )? (v):(-(v))) // Absolute value //====================== GLOBAL CONSTANTS ================================================================== #define MAX_NUM_ROWS 5 // Max. number of rows. #define MAX_NUM_COLS 6 // Max. number of columns. #define MAX_KEY_PAIRS 15 // Max. number of [row, col] key pairs. <*** your GLOBAL CONSTANTS definitions here ***> int main(int argc, char *argv[]) { //============================== setbuf(stdout, NULL); // Turns standard output buffering off <*** Your Variable Declarations here ***> // "scrambled" - 2D Character Array storing adhoc characters. char scrambled[MAX_NUM_ROWS][MAX_NUM_COLS] = {{"zd_k83"}, {"Ju9_Tn"}, {"bgm7If"}, {"ax0DLU"}, {"p_QoiR"} }; // "Key" - 2D Integer Array storing the message key pairs [row, col]. // Note: The range of the row, col pair values stored in the "key" // array is as shown below: // [row, col] ==> [1...5, 1...6], not [0...4, 0...5]!!! int key[MAX_KEY_PAIRS][2] = {{3,5}, {5,2}, {4,1}, { , }, // Fill these spaces with right numbers {1,3}, { , }, // Fill these spaces with right numbers {5,4}, {5,5}, { , }, // Fill these spaces with right numbers {3,2}, {2,4}, { , }, // Fill these spaces with right numbers {4,1}, { , }, // Fill these spaces with right numbers {1,6} }; <*** Your Program Code here ***> return 0; } 

The program output should get the decoded message: [I am doing Lab3]

 ::: Decoded Message: [I am doing Lab3] ::: ::: Program Terminated. ::: 

The "scrambled" and "key" arrays are initialized at declaration time with the shown values. As such, your program does not need to perform any input. All of the required information is already stored in these two arrays. The message encoded in the "scrambled" array is decoded as follows:

Get the [row, col] pair of values from the "key" array.

Use the [row, col] values to retrieve the character stored in the "scrambled" array.

Concatenate the retrieved characters from left to right, and in the order that they are retrieved, to form the message.

If the message contains underscore (_) characters, replace each underscore with a space/blank character.

Finally, output the hidden message.

The "Global Macro Definitions" shown in the program template are included for your peruse, should you wish to use them.

PLEASE NOTE:: You may use any array indexing method of your choice: Array Index, Pointer Index, or Pointer Arithmetic. However, you MUST use either the strcat() or strncat() string concatination functions to build the decoded "message".

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions