For some reason that I'm not aware of, array from main() doesn't get to be modified when it should. Isn't "a"
passed by reference? Can someone please guide me a little bit?
Here is the code:
#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();*/
}