Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Ex no.3 - Tran Viet Anh - 12:17PM
- #include<iostream>
- using namespace std;
- int main()
- {
- int n; cin >> n;
- int a[n];
- for (int i = 0; i < n; i++)
- cin >> a[i];
- int start = 0, end, max = 0, maxStart, maxEnd;
- for (int i = 1; i < n; i++)
- if (a[i] < a[i - 1])
- {
- if (i - 1 - start > max)
- {
- max = i - 1 - start;
- maxStart = start;
- maxEnd = i - 1;
- }
- start = i;
- }
- if (n - 1 - start > max)
- {
- maxStart = start;
- maxEnd = n - 1;
- }
- for (int i = maxStart; i <= maxEnd; i++)
- cout << a[i] << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement