35657

Untitled

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