Advertisement
Guest User

insertion

a guest
May 30th, 2015
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2. #define VELIKOST 5
  3. int main(void)
  4. {
  5.     int iStevec,iStevec1,iPrehod,iZacasna,iPozicija,iPolje[VELIKOST];
  6.     printf("Algoritem urejanja z navadnim izbiranjem, angl.Selection sort\n");
  7.     for(iStevec=0;iStevec<VELIKOST;iStevec++)
  8.     {
  9.         printf("Vnesite %i vrednost polja:", iStevec+1);
  10.         fflush(stdin);
  11.         scanf("%i", &iPolje[iStevec]);
  12.     }
  13.    
  14.     for(iPrehod=1;iPrehod<VELIKOST;iPrehod++)
  15.     {
  16.         iPozicija=iPrehod;
  17.         while(iPozicija>0 && iPolje[iPozicija]<iPolje[iPozicija-1])
  18.         {
  19.             iZacasna=iPolje[iPozicija];
  20.             iPolje[iPozicija]=iPolje[iPozicija-1];
  21.             iPolje[iPozicija-1]=iZacasna;
  22.             iPozicija--;
  23.         }
  24.     }
  25.     printf("\n Po urejanju\n\n");
  26.     for(iStevec=0;iStevec<VELIKOST;iStevec++)
  27.     {
  28.         printf("%i ", iPolje[iStevec]);
  29.     }
  30.     return (0);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement