这个选择排序,怎么结果还所原来的数字
#include<stdio.h>#include<stdlib.h>
#define LEN sizeof(arr)/sizeof(arr[0])
void swap(int *p , int *q)
{
int temp = *p;
*p = *q;
*q = temp;
}
void arr_print(int *arr, int len)
{
int i;
for (i=0; i<len; i++)
printf("%d ",arr[i]);
printf("\n");
}
int main()void select_sort(int arr[])
{
int min_idx, i, j;
for (i = 0; i<LEN; i++)
{
min_idx = i;
for (j=i; j<LEN;j++)
{
if(arr[j]<arr[min_idx])
{
min_idx = j;
}
}
swap(&arr[i], &arr[min_idx]);
}
}
{
int i,j;
int arr[] = { 3, 9, 2, 7, 10, 8, 4, 6, 5, 1};
select_sort(arr);
arr_print(arr, LEN);
return 0;
}
结果 根本就没有变