Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have task for creating algorithm in c# that will order some results with the following rule:

if A > B and C > B => A, C, B ....

Thanks

What I have tried:

i haf tried with bubble sort but it messing but results.
Posted
Updated 18-Mar-17 2:19am
Comments
Richard MacCutchan 18-Mar-17 7:57am    
"but it messing but results."
Sorry, but that does not mean anything. Please edit your question, show the code you are using and explain exactly what the problem is.
[no name] 18-Mar-17 8:12am    
if A > B and C > B => A, C, B ....

And if it is not? What then? Which one of the 7 remaining possibilities you Need to choose?
B,C,A
or C,B,A
or....
OriginalGriff 18-Mar-17 8:13am    
And even then, what is C is also greater than A?
OriginalGriff 18-Mar-17 8:22am    
Nah, he's very specific on that one! :laugh:
[no name] 18-Mar-17 8:30am    
sorry for the bunch of messages just before. But while replying to you, the message was always shown in as reply to Ralf Meier's comment below.
This with IE, I should finally change to another browser :)

Start here: Bubble sort - Wikipedia[^] - it explains it, demonstrates it, and it even provides pseudo code that you can translate into C# (or any other language since you ask for three).

This is your homework: we don't do it for you. Give it a try, and if you meet a specific problem ask about that (showing us what you tried, how you tested it, and explaining what happened when you did) and we will be happy to help you - but we are not going to do it all for you!
 
Share this answer
 
Comments
Ralf Meier 18-Mar-17 8:18am    
OK ... you are some seconds earlier than I with my comment ... :(
[no name] 18-Mar-17 8:46am    
Hello Ralf
Your comment to the question is deleted. Maybe it was me... In case it was me it was unintentional. Sorry if it was me.
Bruno
Quote:
if A > B and C > B => A, C, B ....

Check that rule, it is wrong.
Show your work, explain the problem and you will get help.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.
 
Share this answer
 
v2
Comments
[no name] 18-Mar-17 8:47am    
Not fair to downvote this. Added a 5.
Patrice T 18-Mar-17 8:57am    
Thank you very much.
Looks like some people get pleasure in downvoting about anything.
I have just been downvoted on an sql injection advice.
[no name] 18-Mar-17 9:09am    
Adjusted the one, as far as I can :)
Patrice T 18-Mar-17 9:10am    
Thank you again
[no name] 18-Mar-17 9:18am    
"Check that rule, it is wrong."
I think it is just a rule and why the rule should be wrong. The question for me is more what happens when the rule Returns "false", how to proceed then, what is the order rule then ;)

btw a 5 year member is most probably not try to solve homework, I hope .... :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900