<分区>
由于某些我不知道的原因,main() 中的数组在应该修改的时候没有得到修改。 "a"
不是通过引用传递的吗?有人可以指导我一下吗?
代码如下:
#include "stdio.h"
void sort(int list[])
{
//int list[] = { 4, 3, 2, 1, 10 };
int n = sizeof(list) / sizeof(int);
int min = 0;
int temp = 0;
for (int i = 0; i < n; i++)
{
min = i;
//profiler.countOperation("compSort", n, 1);
for (int j = i + 1; j < n; j++)
{
if (list[j] < list[min])
{
min = j;
//profiler.countOperation("compSort", n, 1);
}
}
if (min != i)
{
//profiler.countOperation("compSort", n, 1);
temp = list[min];
list[min] = list[i];
list[i] = temp;
}
}
}
int main()
{
int a[5] = {4, 3, 2, 1, 10};
sort(a);
printf("%d\n", a[0]);
for (int i = 0; i < 5; i++)
{
printf("%d", a[i]);
}
return 0;
/*int arr[MAX_SIZE];
for(int t = 0; t < 1; t++)
{
for (int n = 100; n < 3000; n = n + 300)
{
FillRandomArray(arr, n);
sort();
printf("done %d \n", n);
if (!IsSorted(arr, n)
{
printf("error sort \n");
}
}
}
profiler.addSeries("TotalSort", "cmpSel", "atribSel");
profiler.createGroup("SortMediu", "TotalSort", "cmpSel", "atribSel");
profiler.showReport();*/
}