Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the code has errors it gives the wrong out put when ever i try test case (0) and test case (3). if could please fix

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedthe code has errors it gives the wrong out put when ever i try test case (0) and test case (3). if could please fix the code and write a int main for both functions,

this is the code :

void ArrPrint (const string phrases [][ColumnSize], int RowSize, bool dir, bool oppo) { if (dir == 0) { if (oppo == 0) { for (int i = 0; i = 0; i--) { for (int j = 0; j = 0; j--) { for (int i = 0; i

string ArrMax (const string phrases [][ColumnSize], int RowSize, int rowNum, int colNum) { string max = ""; if (rowNum == -1 && colNum == -1) { for (int i = 0; i max) { max = phrases[i][j]; } } } } else if (rowNum == -1) { for (int i = 0; i max) { max = phrases[i][colNum]; } } } else if (colNum == -1) { for (int j = 0; j max) { max = phrases[rowNum][j]; } } } return max; }

HW7: Two-Dimensional Arrays You are required to write two functions called ArrPrint and ArrMax according to the following specifications: - Function ArrPrint: takes as input a two-dimentional array of type string (i.e. phrases), an integer variable (i.e. RowSize), and two boolean variables (i.e. dir and oppo). This function is responsible for printing the array row-by-row (when dir =0 ) or column-by-column (when dir =1 ) such that each row/column is printed in normal order (when oppo =0 ) or in reverse order (when oppo =1 ). Notice that the function should print a single-space after each element. - Function ArrMax: takes as input a two-dimentional array of type string (i.e. phrases) and three integer variables (i.e. RowSize, rownum, and colNum). This function is responsible for returning the largest string in the row specified by rowNum (when colNum =1 ), the largest string in the column specified by colNum (when rowNum = -1), or the largest string in the entire array phrases (when rowNum = -1 and colNum = -1). Do not write and submit the main subroutine, or any include statments, these are already written and hidden from you. However, if you want to test your solution in any IDE (e.g., CodeBlocks, CLion, onlinegdb.com), then you will need to write your own main there for testing purposes. IMPORTANT NOTES - Do not change the given functions headers. - Do not add any cout statements inside the function ArrMax. - Assume a global constant variable called ColumnSize is defined to determine the number of columns in the two-dimentional array. - The parameter RowSize in both functions represents the number of filled rows in the two-dimentional array. - Your code should work correctly regardless the values of ColumnSize and RowSize. Sample Testcase 0 (not graded, for student use only): Input: Suppose main calls ArrPrint as ArrPrint(phrases,2,0,1) and phrases is initialized as {{ "The", "weather", "is", "really", "cold"\}, { "Qatar", "hosted", "the", "World", "Cup"\}\}, then the output would be: Function Output: cold really is weather The Cup World the hosted Qatar Sample Testcase 3 (not graded, for student use only): Input: Suppose main calls ArrPrint as ArrPrint(phrases,2,1,1) and phrases is initialized as {{ "The", "weather", "is", "really", "cold"\}, \{"Qatar", "hosted", "the", "World", "Cup"\}\}, then the output would be: Function Output: Qatar The hosted weather the is World really Cup cold Compilation suceeded Grading sample test cases .... sample test case 0 failed (incorrect output) sample test case 1 succeeded sample test case 2 succeeded sample test case 3 failed (incorrect output) sample test case 4 succeeded sample test case 5 succeeded sample test case 6 succeeded Grading secret test cases .... secret test case 0 failed (incorrect output) secret test case 1 succeeded secret test case 2 succeeded secret test case 3 failed (incorrect output) secret test case 4 succeeded secret test case 5 succeeded secret test case 6 succeeded

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

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions