Advertisement
Guest User

Sortowanie przez wybieranie

a guest
Dec 12th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. #include <stdio.h>
  2. int main (void)
  3. {
  4. int tab[6] = {4,2,5,3,6,1};
  5. int pom;
  6. int k;
  7. for(int i=0;i<6;i++)
  8. {
  9.     k=i;
  10.     for(int j=i+1;j<6;j++)
  11.     {
  12.       if(tab[j]<tab[k])
  13.       {
  14.         k=j;
  15.       }
  16.  
  17.     }
  18.     pom=tab[k];
  19.     tab[k]=tab[i];
  20.     tab[i]=pom;
  21.  
  22. }
  23. for(int i=0;i<6;i++)
  24. {
  25. printf("%d ", tab[i]);
  26. }
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement