Advertisement
sellmmaahh

OR-postavke2-zad3

Aug 13th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. int Fja (int *niz,int vel) {
  5.    int i, max_prost=0, min_prost=10000, j, prost=1,br_prostih=0;
  6.    for (i=0; i<vel; i++) {
  7.         for (j=2; j<niz[i]; j++)
  8.         {  if (niz[i]%j==0)
  9.             prost=0;
  10.         }
  11.         if (prost==1) {
  12.                 br_prostih++;
  13.                 if (niz[i]>max_prost) max_prost=niz[i];
  14.                 else if (niz[i]<min_prost) min_prost=niz[i];
  15.         }
  16.  
  17.    }
  18.    if (br_prostih==0) return -1;
  19.    return max_prost-min_prost;
  20. }
  21. int main () {
  22.     int niz[5]={13,3,4,6,8};
  23.     printf("%d",Fja(niz,5));
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement