Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- // Given an array A (6,6).
- // Find the minimum among the elements in the odd rows of the array and located above the main diagonal.
- const int ROWS_COUNT = 6;
- const int COLUMNS_COUNT = 6;
- int main() {
- srand(time(nullptr));
- int A[ROWS_COUNT][COLUMNS_COUNT]{};
- int min{INT32_MAX};
- for (int i = 0; i < ROWS_COUNT; ++i) {
- for (int j = 0; j < COLUMNS_COUNT; ++j) {
- A[i][j] = 10 + rand() % 90;
- if ( (i+1 % 2 != 0) && (j > i) ) {
- if (A[i][j] < min) {
- min = A[i][j];
- }
- }
- std::cout << A[i][j] << " ";
- }
- std::cout << std::endl;
- }
- std::cout << "\nMinimum: " << min << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement