?
#include<iostream>
using namespace std;
#define N 100
#define M 100
//输入二维数组
void input(int n, int m, int a[][M]) {
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) {
int x;
cin >> x;
a[i][j] = x;
}
}
//在每行里找最大值并输出
int max(int(*p)[M], int i, int m) {
int f = 0;
for (int j = 0; j < m; j++) {
cout << p[i][j] << endl;
if (p[i][j] > f)f = p[i][j];
}
return f;
}
int main() {
int a[N][M] = {};
int n, m;
cin >> n >> m;
input(n, m, &a[0]);
for (int i = 0; i < n; i++) {
max(a+i, i, m);
}
return 0;
}
我看了好久还是没有发现具体是指针的哪里错了,只知道是max函数里只能显示第一行的数,其余都为0,明天继续吧
|