Back
MaxMin.cpp
Save
// MaxMin.cpp #include
using namespace std; float Max(float a[], int l, int r) { if (r == l) return a[l]; else { int m = (l + r) / 2; float max1 = Max(a, l, m); float max2 = Max(a, m + 1, r); if (max1 > max2) return max1; return max2; } } int main() { float a[] = {1.2, 3.4, 4.5, 9.1, 6.3, 7.2, 5.4, 4.6, 4.9, 8.5, 9.9, 0.5, 6, 8, 10.6}; cout << "Gia tri lon nhat la: " << Max(a, 0, 14) << endl; return 0; }