Advertisement
STANAANDREY

T10/6/2020 1

Oct 6th, 2020 (edited)
882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. void read(int v[], int &n) {
  6.     ifstream fin("nr.txt");
  7.     fin >> n;
  8.     for (int i = 0; i < n; i++)
  9.         fin >> v[i];
  10.     fin.close();
  11. }
  12.  
  13. int getMin(int v[], int p, int q) {
  14.     if (p == q)
  15.         return v[p];
  16.     int mid = (p + q) / 2;
  17.     int mini1 = getMin(v, p, mid);
  18.     int mini2 = getMin(v, mid + 1, q);
  19.     return mini1 > mini2 ? mini2 : mini1;
  20. }
  21.  
  22. int main() {
  23.     int n, v[1000];
  24.     read(v, n);
  25.     cout << getMin(v, 0, n - 1) << endl;
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement