View Code of Problem 49

#include <stdio.h>
int main()
{
	int a[10];
	int b;
	int i;
	int k;
	int j;
	int temp;
	scanf("%d", &b);
    for( i = 0;i<b;i++)
    scanf("%d", &a[i]);
    for(i = 0;i<b;i++)
	{
		k = i;
		for(j = i+1;j<b;j++)
		if(a[j]<a[k])
		{
		k = j;
	    }
		temp = a[i];
		a[i] = a[k];
		a[k] = temp;
		
		
	 } 
	 for(i = 0;i<b;i++)
	 {
printf("%d ", a[i]);

}

	return 0;
	
}

Double click to view unformatted code.


Back to problem 49