| atroposi (3) | |||
|
hello, i am a c++ noob, here is my work on quick sort problem, i don't know why it doesn't work, any one can point out the mistake will be very thankful.
| |||
|
Last edited on
|
|||
| Fransje (245) | |||
Your Swap function should look like this:
Notice the ampersand (&) signs? They tell the compiler that any changes made to x and y should be applied to the original variables that you passed to the function. This is called passing by reference. Here an explanation in detail: http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/ and here a general explanation about references: http://www.learncpp.com/cpp-tutorial/611-references/ | |||
|
Last edited on
|
|||
| Darkmaster (494) | |
|
@ fransje: or just use std::swap http://www.cplusplus.com/reference/algorithm/swap/ | |
|
|
|
| atroposi (3) | |
|
still doesn't work it seems some wrong in the QuickSort block however i cant figure it out | |
|
|
|
| georgewashere (238) | |
| attach the debugger and see where you are going wrong. | |
|
|
|
| shahzaib1111 (17) | |||
swap code should be like this
and call it like this Swap (&array[i], array[&pivotPlace]);
| |||
|
|
|||
| atroposi (3) | |||||
|
thanks all i revised the swap function and the line 43
to be like this
than it works | |||||
|
|
|||||