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_rows[2];
- 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 i = 0; i < 2; i++) {
- sum_rows[i] = 0;
- for (size_t j = 0; j < 7; j++) {
- cout << matrix[i][j] << " ";
- sum_rows[i] = sum_rows[i] + matrix[i][j];
- }
- cout << sum_rows[i] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement