Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////
- // Задачата събира матрицата по колони и извежда сумата под колоната. //
- ////////////////////////////////////////////////////////////////////////
- #include <iostream>
- #include <ctime>
- using namespace std;
- int main() {
- srand(time(0));
- int matrix[2][7];
- int sum_columns[7];
- for (size_t i = 0; i < 2; i++) {
- for (size_t j = 0; j < 7; j++) {
- matrix[i][j] = rand() % (9 - 1);
- }
- }
- for (size_t j = 0; j < 7; j++) {
- sum_columns[j] = 0;
- for (size_t i = 0; i < 2; i++) {
- sum_columns[j] = sum_columns[j] + matrix[i][j];
- }
- }
- for (size_t i = 0; i < 2; i++) {
- for (size_t j = 0; j < 7; j++) {
- cout << matrix[i][j] << " ";
- }
- cout << endl;
- }
- for (size_t i = 0; i < 7; i++) {
- cout << sum_columns[i] << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement