Advertisement
gasaichan

Untitled

Oct 9th, 2017
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <time.h>
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include <conio.h>
  5. #include <clocale>
  6.  
  7. #define SIZE 5
  8.  
  9. using namespace std;
  10.  
  11. int main() {
  12.     srand(time(0));
  13.     setlocale(LC_ALL, "Russian");
  14.     int Arr[SIZE][SIZE];
  15.     for (int i = 0; i < SIZE; i++) {
  16.         for (int j = 0; j < SIZE; j++) {
  17.             Arr[i][j] = rand() % 100;
  18.             // Этот cout для вывода, можно его удалить, если не нужен
  19.             cout << Arr[i][j] << "\t";
  20.         }
  21.         // Этот тоже
  22.         cout << endl;
  23.     }
  24.  
  25.     int Max = Arr[0][0];
  26.     for (int i = 0; i < SIZE; i++) {
  27.         for (int j = 0; j < SIZE; j++) {
  28.             if (j >= i && j <= SIZE / 2) {
  29.                 if (Arr[i][j] > Max) {
  30.                     Max = Arr[i][j];
  31.                 }
  32.             }
  33.         }
  34.     }
  35.  
  36.     cout << "Максимальный элемент равен " << Max << endl;
  37.     _getch();
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement