Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, i, maxim = 0, minim, t[1000], b = 0, c = 0;
- cin >> n;
- for (i = 1; i <= n; i++)
- {
- cin >> t[i];
- }
- for (i = 1; i <= n; i++)
- {
- if (i > maxim)
- {
- maxim = t[i];
- b = i;
- }
- }
- minim = maxim;
- for (i = 1; i <= n; i++)
- {
- if (i < minim)
- {
- minim = t[i];
- c = i;
- }
- }
- if (b > c)
- {
- for (i=b; i <= c; i++)
- {
- cout << t[i] << " ";
- }
- }
- else if (c > b)
- {
- for (i=c; i <= b; i++)
- {
- cout << t[i];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement