Advertisement
Avdluna

Untitled

Oct 14th, 2015
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int n,i,x[10001],a=1,f=0;
  7.  
  8.         do{
  9.            scanf("%d",&n);
  10.  
  11.                 for(i=0 ; i<n ; i++){
  12.                     scanf("%d",&x[i]);
  13.                 }
  14.  
  15.                 for(i=0 ; i<n ; i++){
  16.                     if((x[a] > x[i] && x[a] > x[i+1]) || (x[a] < x[i] && x[a] < x[i+i])){
  17.                         f++;
  18.                         a++;
  19.                     }
  20.                 }
  21.  
  22.                 if((x[0] > x[n] && x[0] > x[1]) || (x[0] < x[n] && x[0] < x[1])){
  23.                     f++;
  24.                 }
  25.             printf("%d\n",f);
  26.             f=0;
  27.                     }while(n != 0);
  28.  
  29.  
  30.  
  31.     return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement