Skip to content

Instantly share code, notes, and snippets.

@haad
Created November 8, 2012 00:17
Show Gist options
  • Save haad/4035580 to your computer and use it in GitHub Desktop.
Save haad/4035580 to your computer and use it in GitHub Desktop.
sofi C
#include <stdio.h>
#include <stdlib.h>
void swap(int *pa, int *pb)
{
int c;
c = *pa;
*pa = *pb;
*pb = c;
}
int indexofmin(int p[],int pocet,int from)
{
int indexmin;
int i;
indexmin=from;
for(i=from;i<pocet;i++)
{
if(p[i]<p[indexmin])
indexmin=i;
}
return indexmin;
}
void sort(int p[],int size)
{
int x;
int from;
for (from=0;from<size;from++)
{
x=indexofmin(p,6,from);
swap(&p[x],&p[from]);
}
}
int main()
{
int p[]={5,2,3,3,9,1,4};
int i;
sort(p,7);
for(i=0;i<7;i++)
printf("%d",p);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment