I've been going crazy about this, I watched week 4's lectures, search in here for similar problems, but it seems everyone got pass this step easily. Here's my code (I passed in numbers 5 4 3 2 1)
void sort(int values[], int n)
{
int temp;
for (int i=0; i < n-1; i++)
{
int min=i;
for (int j=i+1; j < n; j++)
{
if (values[j] < values [min])
{
min = j;
}
}
temp = values[min];
values[min] = values[i];
values[i] = temp;
}
}
And here's GDB
(gdb) info locals
j = 2
i = 1
(gdb) p values[0]
$4 = 5
(gdb) p values[1]
$5 = 5
i=1, so values[0] must be sorted if the codes worked, but it's all 5 the rest of the array. Because Zamyla says when passed in an array, it's the array itself, so I didn't use pointers here. Please help....