Advertisement
DasShelmer

8.2.19

Dec 3rd, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. static int li = -1, lj = -1, min = ~(1 << 31);// lenght
  5. int getMin(int** arr, int &i, int &j) {
  6.     if (i >= li || j >= lj)
  7.         return min;
  8.     if (arr[i][j] < min)
  9.         min = arr[i][j];
  10.     if (j == lj - 1) {
  11.         j = 0;
  12.         i++;
  13.     }else
  14.     {
  15.         j++;
  16.     }
  17.     return getMin(arr, i, j);
  18. }
  19.  
  20. int main() {
  21.     while (li < 1 || lj < 1) {
  22.         cout << "Enter the row and collum count: ";
  23.         cin >> li >> lj;
  24.     }
  25.     cout << "Enter the array: " << endl;
  26.     int** arr = new int* [li];
  27.     for (int i = 0; i < li; i++) {
  28.         arr[i] = new int[lj];
  29.         for (int j = 0; j < lj; j++) {
  30.             cin >> arr[i][j];
  31.         }
  32.     }
  33.     int i = 0, j = 0;
  34.     cout << "Min value is: " << getMin(arr, i, j);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement