Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int Prost (int n) {
- int i;
- for (i=2; i<n; i++)
- {
- if (n%i==0) return 0;
- }
- return 1;
- }
- void Preslozi (int *niz, int vel) {
- int pom[100],i,prost,p=0;
- for (i=0; i<vel;i++)
- {
- if (Prost(niz[i])==1) pom[p++]=niz[i];
- }
- for(i=0;i<vel; i++) {
- if (Prost(niz[i]==0) && Prost(niz[i])!=1) pom[p++]=niz[i];
- }
- for (i=0; i<vel; i++) {
- niz[i]=pom[i];
- }
- }
- int main () {
- int niz[8]={5,8,7,12,13,16,17,9};
- Preslozi(niz,8);
- int i;
- for (i=0; i<8; i++) printf("%d ",niz[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement