Advertisement
Grizzly0132

Afisareminmax

Mar 17th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6.  
  7. int main()
  8. {
  9. int n, i, maxim = 0, minim, t[1000], b = 0, c = 0;
  10. cin >> n;
  11. for (i = 1; i <= n; i++)
  12. {
  13. cin >> t[i];
  14. }
  15. for (i = 1; i <= n; i++)
  16. {
  17. if (i > maxim)
  18. {
  19. maxim = t[i];
  20. b = i;
  21. }
  22. }
  23. minim = maxim;
  24. for (i = 1; i <= n; i++)
  25. {
  26. if (i < minim)
  27. {
  28. minim = t[i];
  29. c = i;
  30. }
  31. }
  32. if (b > c)
  33. {
  34. for (i=b; i <= c; i++)
  35. {
  36. cout << t[i] << " ";
  37. }
  38. }
  39. else if (c > b)
  40. {
  41. for (i=c; i <= b; i++)
  42. {
  43. cout << t[i];
  44. }
  45. }
  46.  
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement