// 选择排序
void SelectSort(int arr[], int n)
{
int i, j;
int min;
for(i = 0; i < n - 1; i++)
{
int index = 0;
min = arr[i];
for(j = i + 1; j < n; j++) //找出 i+1 - n 无序区的最小者与arr[i]交换
{
if(arr[j] < min)
{
min = arr[j];
index = j;
}
}
if(index != 0) //表明无序区有比arr[i]小的元素
{
arr[i] = arr[i]^arr[index];
arr[index] = arr[i]^arr[index];
arr[i] = arr[i]^arr[index];
}
}
}