求c++编程解答~

来源:百度知道 编辑:UC知道 时间:2024/07/07 11:42:42
(1) Write function void max(int a[][5], int rowsize, int& row, int& col) that locates the maximum in the two-dimensional array a with 5 columns. rowsize is the number of rows in a. row is the row index of the maximum in a. col is the column index of the maximum in a. In this task, we assume all values in array a are different.
(2) In function main, call function max to locate the maximum in the declared two-dimensional array table and display its value and indexes.
输出结果举例:
An example of program execution:
Enter distinct integers for a 2d array with 2 rows and 5 columns.
3 1 5 2 4
8 6 9 7 0
3 1 5 2 4
8 6 9 7 0
The maximum is 9 in row 1 and column 2

注意:Even a space, a typo or a punctuation sign can make a big difference.
格式要求:
#include <iostream>
#include <iomanip>

using namespace std;

// read values for a two-dimentional array
void read2d(int a[][5], int rowsize);

//

#include <iostream>
#include <iomanip>

using namespace std;

// read values for a two-dimentional array
void read2d(int a[][5], int rowsize);

// display the values in a two-dimentional array
void display2d(const int a[][5], int rowsize);

// find the ma and min in 2d array a
void max(int a[][5], int rowsize, int& row, int& col);

int main()
{
int table[2][5];
int rowIndex, colIndex;

cout << "Enter distinct integers for a 2d array with 2 rows and 5 columns." << endl; // don't modify
read2d(table, 2); // don't modify

display2d(table, 2); // don't modify

// write code to locate the maximum in 2d array table
max(table, 2, rowIndex, colIndex);
cout << "The maximum is " << table[rowIndex][colIndex] << " in row " << rowIndex << " and column " &