Question: You are to write a program that will perform calculations with a two dimensional array. The following functions are to be developed to support a
You are to write a program that will perform calculations with a two dimensional array. The following functions are to be developed to support a new development initiated by a local Multi-Optimal-Dimension Company (MAD COMP). Your program should handle any two dimensional square array up to 100 by 100. (Dimension your array 100 by 100) You will need two arrays in your program for some of the functions below. The user will supply you with the dimensions at the time your program starts running. (I will supply you a pseudo program to test you code with.)
You are to development the following functions to support this effort. Write a function for each of the following actions.
Add any two rows together, place results in the second argument (second row)
Subtract any two rows, place results in the second argument.
Add any two columns together, place results in the second argument.
Subtract any two columns, place results in the second argument.
Copy one array into the other: second argument.
Find the largest number in any row.
Find the largest number in any column.
Find the smallest number in any row.
Find the smallest number in any column.
Replace any element in the array with a new value
Ex call: Replace(array, r, c, value)
Print out the array, one row per line. (yes for my test, a row will fit on one line.) Print any ONE row (across the page) Print any ONE column (across the page)
Example function: AddRow( array, firstrow, secondrow) or AddRow( myAry, 3,7)
Input: I will supply you a pseudo main program that will be used to test your functions. I will not be able to give you the actual code, because I will not know the name of your routines or the order of your arguments. You will write the main program to test your code.
Restrictions: You must read in the dimension of the array. You can not have any code in your main program that has the [] syntax. Your declaration for the array in the main program can have [] and only there. Any and all array manipulations must be done in the functions and only in functions. This also includes any new functions you decide to add to the program, ie the new functions you add cannot have [] syntax in them, just the functions stipulated in the program specifications.
For the following, do the operations in the order given below.
Read in the size of the array to be the following:
Rows: 16, Columns: 16 Must be read in and not defined or hard coded in your program.
- Fill the array with the value 1 to 16 on the first row, 17 to 32 on the second row etc for all 16 rows.
Hint: This would look something like the following:
i=0;
for ( r=0; r
for ( c=0; c< maxc; c++)
Replace( ary, r, c, i++); this fills the array
2 print the Array (whole array)
- Add: row 1 = row 1 + row 2
- Add: col 3 = col 3 + col 14
- print col 3 and row 1
- Subtract the sum of row 1 and row 2 from row 4, results in row 4
- Subtract from col 13 col 9, put results in col 12
11. print row 4 and col 12
14. Find the largest value in the Array on row 11 Print it
15. Find the smallest value in the Array on col 5 and col 9. The one smallest value for both columns. Print it
16. Fill row 4 of the Array with three times its column position. 3*col 0 = 0, 3* col 1 = 3, 3*col 2 = 6 etc. for each column.
17. Fill row 5 of the Array with three times its value in row 5. 3*ary[5,i] = ary[5,i], for each value on row 5.
17.5 Print row 4 and row 5
18. Add rows 11, 12, 13 to row 8 of the Array
- print row 8
- Subtract col 3 and col 6 from col 10 of the Array
- print col 10
- Which col has the largest sum? Print the column and the sum.
- Print out the sum of rows 5 through 10, one value.
Run your program again with a new main program to do the following.
New array dimension
- Set up an array with 7 rows and 7 cols.
- Fill array row 0 with 10 20 ..70
- Fill array row 1 with 10 20 .. 70
for all rows
- print array C++ Language
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
