Lucian_Adrian

#986 Numarare7

Dec 4th, 2021
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. float v[201];
  6.  
  7. int main()
  8.  
  9. {
  10.  
  11. short n, i, k=0;
  12.  
  13. float a, b;
  14.  
  15. cin >> n;
  16.  
  17. for (i=1; i<=n; ++i) cin >> v[i];
  18.  
  19. a=v[1]; b=v[n];
  20.  
  21. if (a>b) swap(a, b);
  22.  
  23. for (i=1; i<=n; ++i)
  24.  
  25. if (v[i]<a || v[i]>b) ++k;
  26.  
  27. cout << k;
  28.  
  29. return 0;
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment