#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int n, m;
cout << "Rows: "; cin >> n;
cout << "Columns: "; cin >> m;
int a[n][m];
int all_sum = 0;
float average;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout << "Element[" << i << "][" << j << "] = "; cin >> a[i][j];
}
cout << "\nShow massiv" << endl;
cout << a[i][j] << " ";
cout << endl;
all_sum += a[i][j];
average = all_sum / m;
cout << "Average " << i+1 << " row: " << average << endl;
system("pause");
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int n, m;
cout << "Rows: "; cin >> n;
cout << "Columns: "; cin >> m;
int a[n][m];
int all_sum = 0;
float average;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout << "Element[" << i << "][" << j << "] = "; cin >> a[i][j];
}
}
cout << "\nShow massiv" << endl;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout << a[i][j] << " ";
}
cout << endl;
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
all_sum += a[i][j];
}
average = all_sum / m;
cout << "Average " << i+1 << " row: " << average << endl;
}
system("pause");
}