Advertisement
Josif_tepe

Untitled

Jun 9th, 2024
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. #include <math.h>
  5.  
  6. int funkcija(int *niza, int n) {
  7.     int S = niza[0], E = niza[n - 1];
  8.     if(S > E) {
  9.         S = niza[n - 1];
  10.         E = niza[0];
  11.     }
  12.     int brojac = 0;
  13.     for(int i = 1; i < n - 1; i++) {
  14.         if(niza[i] < S || niza[i] > E) {
  15.             brojac++;
  16.         }
  17.     }
  18.  
  19.     return brojac;
  20. }
  21.  
  22. int main(int argc, char * argv[]) {
  23.     int n;
  24.     scanf("%d", &n);
  25.  
  26.     int niza[n];
  27.     for(int i = 0; i < n; i++) {
  28.         scanf("%d", &niza[i]);
  29.     }
  30.     int res = funkcija(niza, n);
  31.     printf("%d\n", res);
  32. }
  33.  
  34.  
  35. /*
  36. 9
  37. 1 7 0 2 5 0 0 4
  38.  
  39. **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement