35657

Untitled

Nov 25th, 2023
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <time.h> // для подключения функции time()
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9. int main() {
  10.  
  11.     setlocale(LC_ALL, "ru");
  12.  
  13.     const int row = 3;
  14.  
  15.     const int col = 5;
  16.  
  17.     int arr[row][col]; // равносильно int arr[3][5]
  18.  
  19.     srand(time(NULL));
  20.  
  21.     for (int i = 0; i < row; i++) {
  22.         for (int j = 0; j < col; j++) {
  23.             arr[i][j] = rand() % 100;
  24.             cout << arr[i][j] << "\t";
  25.         }
  26.         cout << endl;
  27.     }
  28.  
  29.     for (int i = 0; i < row; i++) {
  30.         int max = arr[i][0];
  31.  
  32.         for (int j = 0; j < col; j++) {
  33.             if (arr[i][j] > max) {
  34.                 max = arr[i][j];
  35.             }
  36.         }
  37.  
  38.         cout << "Максимальное значение для строки " << i + 1 << " - " << max << endl;
  39.     }
  40.  
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment