Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "ru");
- const int row = 3;
- const int col = 4;
- int arr[row][col];
- srand(time(NULL));
- int sum = 0;
- for (int i = 0; i < row; i++) {
- for (int j = 0; j < col; j++) {
- arr[i][j] = rand() % 15;
- }
- }
- for (int i = 0; i < row; i++) {
- int row_sum = 0;
- for (int j = 0; j < col; j++) {
- cout << arr[i][j] << "\t";
- row_sum += arr[i][j];
- }
- sum += row_sum;
- cout << "|\t" << row_sum << endl;
- }
- cout << "---------------------------------" << endl;
- for (int i = 0; i < col; i++) {
- int col_sum = 0;
- for (int j = 0; j < row; j++) {
- col_sum += arr[j][i];
- }
- cout << col_sum << "\t";
- }
- cout << " \t" << sum << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment