Răspuns:
#include <iostream>
using namespace std;
int i, j, m, n, s = 0;
double mt[51][51];
void inserareMedie(int &n, int &m, double mt[51][51],int k) {
double s = 0;
for (int j = 0; j < m; j++) {
s=0;
for (int i = 0; i < n; i++)
s = s+ mt[i][j];
mt[n][j] = s / n;}
for (int j = 0; j < m; j++) {
s=mt[n][j];
for (int i = n ; i >=k + 1; i--) {
mt[i][j] = mt[i - 1][j];
}
mt[k ][j] = s;
}
++n;
}
void afisare(int n, int m, double mt[51][51]) {
cout << "noua matrice :\n "; cout << endl;
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++)
cout << mt[i][j] << " ";
cout << endl;
}
}
int main() {
int n = 2, m = 2;
double mt[51][51] = { {1,1}, {2,2} };
inserareMedie(n, m, mt, 1);
afisare(n, m, mt);
cout << n << " " << m;
}
Explicație: