#include <stdio.h>

int cmp(int x,int y)
{
	return x<y;
}

void swap(int *x,int *y)
{
	int tmp = *x;
	
	*x = *y;
	*y = tmp;
}

size_t select(int p[],size_t len)
{
	size_t pos = 0;
	
	for(size_t i = 0;i<len;++i){
		if(cmp(p[i],p[pos])){
			pos = i;
		}
	}
	
	return pos;
}

void disp(int p[],size_t len)
{
	for(size_t i= 0;i<len;++i){
		printf("%d",p[i]);
	}
	printf("\n");
}

int main(void)
{
	int a[] = {3,1,4,1,5,9,2,6,5};
	size_t n = sizeof a / sizeof a[0];
	
	for(size_t i = 0;i<n-1;++i){
		
		size_t j = i + 1 + select(a+i+1,n-i-1);
		if(cmp(a[j],a[i])){
			swap(a+i,a+j);
		}
		
	}
	
	disp(a,n);
	
	return 0;
}
