Ok this is the code for sorting I have written but now I don't know what file to compile to check for my results. Because of the addition of printf()
function I have added stdio.h into my helpers.c but still I am not getting my printf()
s. Tried compiling with ./generate 10 50 | ./find 12
still no result. I can't get my sorting list printed out. Am i missing some key thing here?
void sort(int values[], int n)
{
// TODO: implement an O(n^2) sorting algorithm
int i, j, k;
for ( j = 0; j < n - 1; j++)
{
for (i = 0; i < n - j; i++)
{
if (values[i] > values[i +1])
{
int temp = values[i] ;
values[i] = values[i+1] ;
values[i+1] = temp ;
}
}
}
return;
for ( k = 0; k < n; k++)
{
printf("no %i : %i\n", k , values[k]);
}
}
Or am I supposed to make another file paste this code in there and get an array of lets say 10 ints through GetInt() and than see if I am getting the desired sorted list or not?