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