Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- void read(int v[], int &n) {
- ifstream fin("nr.txt");
- fin >> n;
- for (int i = 0; i < n; i++)
- fin >> v[i];
- fin.close();
- }
- int getMin(int v[], int p, int q) {
- if (p == q)
- return v[p];
- int mid = (p + q) / 2;
- int mini1 = getMin(v, p, mid);
- int mini2 = getMin(v, mid + 1, q);
- return mini1 > mini2 ? mini2 : mini1;
- }
- int main() {
- int n, v[1000];
- read(v, n);
- cout << getMin(v, 0, n - 1) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement