Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- string *x;
- int n;
- string TimMin(string *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;
- string MinLeft = TimMin(x,Left,Mid);
- string 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 string[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;
- }
Add Comment
Please, Sign In to add comment