Advertisement
Josif_tepe

Untitled

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