Advertisement
Josif_tepe

Untitled

Jan 21st, 2023
940
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6. int eprost(int broj) {
  7.     int broj_na_deliteli = 0;
  8.     for(int i = 1; i <= broj; i++) {
  9.         if(broj % 2 == 0) {
  10.             broj_na_deliteli++;
  11.         }
  12.     }
  13.     if(broj_na_deliteli > 2) {
  14.         return 0;
  15.     }
  16.     else {
  17.         return 1;
  18.     }
  19. }
  20. int rekurzija(int *niza, int n, int i) {
  21.     if(i >= n) {
  22.         return 1;
  23.     }
  24.    
  25.     if(eprost(niza[i])) {
  26.         return rekurzija(niza, n, i + 2);
  27.     }
  28.     else {
  29.         return 0;
  30.     }
  31. }
  32. int main(int argc, char * argv[])
  33.  
  34. {
  35.     int n;
  36.     scanf("%d", &n);
  37.    
  38.     int niza[n];
  39.     for(int i = 0; i < n; i++) {
  40.         scanf("%d", &niza[i]);
  41.     }
  42.    
  43.     printf("%d\n", rekurzija(niza, n, 0));
  44.    
  45.  
  46.    
  47.     return 0;
  48.  
  49. }
  50. /*
  51.  6 8
  52.  1 2 3 4 5 6 7 8
  53.  2 1 2 3 4 5 6 7
  54.  3 4 5 6 7 8 9 10
  55.  4 5 6 7 8 9 10 0
  56.  5 6 7 8 9 10 0 1
  57.  6 7 8 9 10 0 1 2
  58.  
  59.  
  60.  
  61.  
  62.  */
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement