SHARE
TWEET

Untitled

a guest Sep 20th, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int interval(int a[100], int n){
  5.  
  6.     int i,nrEl = 2;
  7.     for (i = 1; i < n - 1; i++){
  8.  
  9.         if ((a[i] >= a[0] && a[i] <= a[n - 1]) ||
  10.             (a[i] <= a[0] && a[i] >= a[n-1]))
  11.                 nrEl++;
  12.  
  13.     }
  14.  
  15.     return nrEl;
  16. }
  17. int main(){
  18.  
  19.     int n;
  20.     cin>>n;
  21.    
  22.     int i,a[100];
  23.     for (i = 0; i < n; i++)
  24.         cin>>a[i];
  25.    
  26.     cout<<interval(a,n);
  27.    
  28.     return 0;
  29.  
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top