<分区>
我有这个作业。基本上,我要做的是完成以下代码,该代码返回“r”行和“n”列的二维数组的最大元素。
#include <stdio.h>
int max_element(int **A, int r, int n) {
// complete the code
int max;
max = a[0][0];
for (int i = 0; i < r; i++) {
for (int j = 0; j < n; j++) {
if (A[i][j] > max)
max = A[i][j];
}
}
return max; }
// implement a main() function to test the algorithm
int main() {
int A[2][3] = { {1, 0, 4}, {10, 3, 1} };
printf("%d\n", max_element(&A, 2, 3));
return 0; }
我有 1 个警告:
- 从不兼容的指针类型 [-Wincompatible-pointer-types] 传递 'max_element' 的参数 1
控制台停止工作:出现问题导致程序停止正常工作...