Advertisement
sellmmaahh

OR-skriptica zad5-proste na pocetak

Aug 16th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int Prost (int n) {
  5. int i;
  6. for (i=2; i<n; i++)
  7. {
  8.     if (n%i==0) return 0;
  9. }
  10. return 1;
  11. }
  12.  
  13. void Preslozi (int *niz, int vel) {
  14.     int pom[100],i,prost,p=0;
  15.     for (i=0; i<vel;i++)
  16.     {
  17.         if (Prost(niz[i])==1) pom[p++]=niz[i];
  18.     }
  19.     for(i=0;i<vel; i++) {
  20.         if (Prost(niz[i]==0) && Prost(niz[i])!=1) pom[p++]=niz[i];
  21.     }
  22.     for (i=0; i<vel; i++) {
  23.         niz[i]=pom[i];
  24.     }
  25. }
  26.  
  27.  
  28.  
  29.  
  30.  
  31. int main () {
  32.   int niz[8]={5,8,7,12,13,16,17,9};
  33.    Preslozi(niz,8);
  34.    int i;
  35.    for (i=0; i<8; i++) printf("%d ",niz[i]);
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement