Удалить elem2.cpp
This commit is contained in:
61
elem2.cpp
61
elem2.cpp
@@ -1,61 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
|
|
||||||
#define N 3
|
|
||||||
#define M 4
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
setlocale(0, "");
|
|
||||||
srand(time(0));
|
|
||||||
|
|
||||||
int arr[N][M]{ 0 };
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
int sum_r[N]{ 0 };
|
|
||||||
int sum_c[M]{ 0 };
|
|
||||||
int sum_all = 0;
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < N; ++i) {
|
|
||||||
for (j = 0; j < M; ++j) {
|
|
||||||
arr[i][j] = rand() % 55 + 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << "Показати масив (рядки):\n";
|
|
||||||
for (i = 0; i < N; ++i) {
|
|
||||||
for (j = 0; j < M; ++j) {
|
|
||||||
sum_r[i] += arr[i][j];
|
|
||||||
cout.width(4);
|
|
||||||
cout << arr[i][j];
|
|
||||||
}
|
|
||||||
cout << " | " << sum_r[i] << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < M + 2; ++i) {
|
|
||||||
cout << "----";
|
|
||||||
}
|
|
||||||
cout << endl;
|
|
||||||
|
|
||||||
for (j = 0; j < M; ++j) {
|
|
||||||
for (i = 0; i < N; ++i) {
|
|
||||||
sum_c[j] += arr[i][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < N; ++i) {
|
|
||||||
sum_all += sum_r[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < M; ++j) {
|
|
||||||
cout.width(4);
|
|
||||||
cout << sum_c[j];
|
|
||||||
}
|
|
||||||
cout << " | " << sum_all << endl;
|
|
||||||
|
|
||||||
system("pause");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user