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?
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?
Last edited by c++prog; 11-07-2009 at 12:30 AM.
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.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Nevermind, I've figured it out by looking up information online and editing the function. Thanks to everyone.
Last edited by c++prog; 11-07-2009 at 12:14 AM.
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.
John 3:16 For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life.
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.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"