This is something that I have been working on but when I compile it I get the can error that says for the line
Could anyone tell me how to fix this?
Printable View
This is something that I have been working on but when I compile it I get the can error that says for the line
Could anyone tell me how to fix this?
Your prototype is wrong:Here's your implementation:Code:void bubblesort(double, int);
See the difference?Code:void bubblesort(double *arraya,int length)//Bubble sort function
I changed the function header to void bubblesort(double *arraya, int length); and now it will compile but it won't sort the array.
Well for one that's not bubblesort. Bubblesort does not use both for loop variables in the inner loop. Instead it uses i-1 or i+1 to compare element i to its neighbour, which causes items to appear to bubble up through the array, and more crucially BubbleSort is stable, whereas that is not.
What you have is also common, but is a different algorithm (apart from the fact that it's slightly broken as well).
If you really mean to implement bubblesort then the best thing you can do is to go and look it up on wikipedia or elsewhere.
Nevermind, I've figured it out by looking up information online and editing the function. Thanks to everyone.
Classy, removing all your code.
The reason I removed all my code was because this was for an assignment and I didn't want anyone to cheat off of it. If you want to see what I have now I can private message it to you.
No one cares about your particular implementation of bubble sort dude, especially since it doesn't even work. And it's not that "we want to see what you have" it's just that you've removed all of the discussion's context.
This is why I sometimes quote the entire original post. Next time I'm doing that.