从键盘输入一个m行n列的二维数组,然后计算数组中元素的最大值及其所在的行列下标值。其中,m和n的值由用户键盘输...
单项选择题从键盘输入一个m行n列的二维数组,然后计算数组中元素的最大值及其所在的行列下标值。其中,m和n的值由用户键盘输入。已知m和n的值都不超过10。在空白处填写适当的表达式或语句,使程序完整并符合题目要求。
#include
#define M 10
#define N 10
void InputMatrix(int *p, int m, int n);
int FindMax(int *p, int m, int n, int *pRow, int *pCol);
int main()
{
int a[M][N], m, n, row, col, max;
printf("Input m,n:");
scanf("%d,%d", &m, &n);
InputMatrix(*a, m, n);
max = FindMax(________________);
printf("max=%d,row=%d,col=%d", max, row, col);
return 0;
}
/* 函数功能:输入m*n矩阵的值 */
void InputMatrix(int *p, int m, int n)
{
int i, j;
printf("Input %d*%d array:", m, n);
for (i=0; i {
for (j=0; j {
scanf("%d", _________);
}
}
}
/* 函数功能:在m*n矩阵中查找最大值及其所在的行列号 */
int FindMax(int *p, int m, int n, int *pRow, int *pCol)
{
int i, j, max = p[0];
*pRow = 0;
*pCol = 0;
for (i=0; i {
for (j=0; j {
if (p[i*n+j] > max)
{
max = ___________;
______________; /*记录行下标*/
______________; /*记录列下标*/
}
}
}
return max;
}
A.
第12行: *a, m, n, &row, &col
第27行: &p[i*n+j]
第44行: p[i*n+j]
第46行: *pRow = i
第48行: *pCol = j
B.
第12行: *a, m, n, &row, &col
第27行: &p[j*n+i]
第44行: p[j*n+i]
第46行: *pRow = j
第48行: *pCol = i
C.
第12行: &a, m, n, row, col
第27行: &p[i*n+j]
第44行: p[i*n+j]
第46行: pRow = i
第48行: pCol = j
D.
第12行: a, m, n, row, col
第27行: &p[j*n+i]
第44行: p[i*n+j]
第46行: *pRow = j
第48行: *pCol = i