Thursday, July 30, 2009

Help with C programming?

i am writing a quick sort program for a C programming class and I can't tell what's wrong. I am getting syntax errors like "[Warning] parameter names(without types in function declaration" and "previous definition of 'sort_nums' was here." What do these mean and how do I fix them. Also I am using recursion if that makes a difference

Help with C programming?
Hard to help you without seeing your source code. Sounds like you may have a problem with mixing up your function **declaration** with your function **defintion(s)**. Review the purpose of each of these things and HOW you do them, and remember that you don't NEED to have a definition at all unless you are calling a function whose DECLARATION is in a different source file or AFTER the call to it. If you do have multiple DEFINITIONs, make sure they are all consistent.
Reply:http://www.cprogramming.com/tutorial.htm...


This link might have what you want. I'm not too up on my C programming
Reply:Now you can call quickSort function ijn your Main Program.








///////////Function To Call Quick Sort//////////


void quickSort(int numbers[], int array_size)


{


q_sort(numbers, 0, array_size - 1);


}


///////////Function To Call Quick Sort//////////


void q_sort(int numbers[], int left, int right)


{


int pivot, l_hold, r_hold;





l_hold = left;


r_hold = right;


pivot = numbers[left];


while (left %26lt; right)


{


while ((numbers[right] %26gt;= pivot) %26amp;%26amp; (left %26lt; right))


right--;


if (left != right)


{


numbers[left] = numbers[right];


left++;


}


while ((numbers[left] %26lt;= pivot) %26amp;%26amp; (left %26lt; right))


left++;


if (left != right)


{


numbers[right] = numbers[left];


right--;


}


}


numbers[left] = pivot;


pivot = left;


left = l_hold;


right = r_hold;


if (left %26lt; pivot)


q_sort(numbers, left, pivot-1);


if (right %26gt; pivot)


q_sort(numbers, pivot+1, right);


}

parts of a flower

No comments:

Post a Comment