Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include "stdafx.h"
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. setlocale(LC_ALL, "Russian");
  8. int n;
  9. int * a;
  10. cin >> n;
  11. a = new int[n];
  12. for (int i = 0; i < n; i++)
  13. {
  14. cin >> a[i];
  15. }
  16. int max = a[0];
  17. for (int i = 1; i < n - 1; i++)
  18. {
  19. if (a[i] > a[i + 1] && a[i] > a[i - 1])
  20. {
  21. max = a[i];
  22. cout << "Локальные максимумы: " << max << endl;
  23. }
  24.  
  25. int main()
  26. {
  27. int n;
  28. int * a;
  29. cin << n;
  30. a = new int[n];
  31. for (int i = 0; i < n; i++)
  32. {
  33. cin >> a[i];
  34. }
  35. int min = a[0];
  36. for (int i = 1; i < n - 1; i++)
  37. {
  38. if (a[i] < a[i + 1] && a[i] < a[i - 1])
  39. {
  40. min = a[i];
  41. cout << "Локальные минимум: " << min << endl;
  42. }
  43. }
  44. return 0;
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement