//===========================================
// 简单选择排序
// Author:Eman Lee
//===========================================
#include<stdio.h>
#define N 10
void Display(int *a, int n)
{
int i;
for (i = 0; i < n; i++) {
printf("%d ", a[i]);
}
printf("\n");
}
void SelectionSort(int *a, int n)
{
int i, j, index, value;
for (i = 0; i < n - 1; i ++) {
index = i;
value = a[i];
for (j = i + 1; j < n; j ++)
if (value > a[j]) {
index = j;
value = a[j];
}
a[index] = a[i];
a[i] = value;
Display(a, n);
}
}
void main()
{
int a[N],i ;
for(i=0;i<N;i++)
a[i]=N-i;
Display(a, N);
SelectionSort(a, N);
}
标签:index,计算机软件,int,void,value,++,printf,2008,排序
From: https://blog.51cto.com/emanlee/8245861