Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- const int tabSize{ 9 };
- const int rows{ 4 };
- const int cols{ 5 };
- int arr[rows][cols]{};
- int colSum[cols]{};
- int sum{ 0 };
- for (int y{ 0 }; y < rows; ++y)
- {
- for (int x{ 0 }; x < cols; ++x)
- {
- arr[y][x] = rand() % 10;
- sum += arr[y][x];
- std::cout << arr[y][x] << '\t';
- colSum[x] += arr[y][x];
- }
- std::cout << "| " << sum << '\n';
- sum = 0;
- }
- for (int x{ 0 }; x <= cols * tabSize; ++x) { std::cout << '-'; }; std::cout << '\n';
- for (int x{ 0 }; x < cols; ++x) { sum += colSum[x]; std::cout << colSum[x] << '\t'; };
- std::cout << "| " << sum << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement