Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- double *x;
- int n;
- double TimMin(double *x,int Left,int Right)
- {
- if (Left == Right)
- {
- return x[Left];
- }
- if (Right == Left + 1)
- {
- if (x[Left] < x[Right]) return x[Left];
- else return x[Right];
- }
- else{
- int Mid = (Left + Right)/2;
- double MinLeft = TimMin(x,Left,Mid);
- double MinRight = TimMin(x,Mid+1,Right);
- if (MinLeft<MinRight) return MinLeft;
- else return MinRight;
- }
- }
- int main()
- {
- cout<<"Nhap so phan tu cua mang: ";
- cin>>n;
- x = new double[n];
- cout<<"Nhap cac phan tu cua mang: ";
- for (int i=0;i<n;i++)
- {
- cin>>x[i];
- }
- cout<<"Phan tu nho nhat cua mang la: "<<TimMin(x,0,n-1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement