View Code of Problem 75

#include <stdio.h>

void SelectSort(int a[], int n) 
{
    int i,j;

	for (i = 0 ; i < n ; i++) 
    {
		int min = i;	//
		int temp;
		for (j = i + 1; j < n; j++){	//
			if (a[j] < a[min]){
				min = j;  
			}
		}
						  		
		temp=a[i];
		a[i]=a[min];
		a[min]=temp;
	}
}

int main()
{
	int a[10];
	int i;
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	
	SelectSort(a,10);
	
	for(i=0;i<10;i++){
		printf("%d\n",a[i]);
	}
	
	return 0;
	
}

Double click to view unformatted code.


Back to problem 75