Advertisement
Daniel_Romanenko

Task 13

Mar 26th, 2023
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4. // Given an array A (6,6).
  5. // Find the minimum among the elements in the odd rows of the array and located above the main diagonal.
  6.  
  7. const int ROWS_COUNT = 6;
  8. const int COLUMNS_COUNT = 6;
  9.  
  10. int main() {
  11.     srand(time(nullptr));
  12.  
  13.     int A[ROWS_COUNT][COLUMNS_COUNT]{};
  14.     int min{INT32_MAX};
  15.  
  16.     for (int i = 0; i < ROWS_COUNT; ++i) {
  17.         for (int j = 0; j < COLUMNS_COUNT; ++j) {
  18.             A[i][j] = 10 + rand() % 90;
  19.  
  20.             if ( (i+1 % 2 != 0) && (j > i) ) {
  21.                 if (A[i][j] < min) {
  22.                     min = A[i][j];
  23.                 }
  24.             }
  25.  
  26.             std::cout << A[i][j] << " ";
  27.         }
  28.         std::cout << std::endl;
  29.     }
  30.  
  31.     std::cout << "\nMinimum: " << min << std::endl;
  32.     return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement