Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
1.07/5 (6 votes)
See more:
1/3,2/5,4/7,.....
Without converting the elements into decimals, sort them.
Hint: treat a1/b1 as (a1,b1) as a pair of numbers. and a1
Posted
Updated 14-Nov-13 4:37am
v2
Comments
BillWoodruff 14-Nov-13 10:18am    
Homework ? Show us some code, describe what you have tried so far.
José Amílcar Casimiro 14-Nov-13 11:21am    
I will give you a hint, you need to find the least common denominator.
Sergey Alexandrovich Kryukov 14-Nov-13 15:05pm    
My 5. Look, this single phrase would make a fair answer if you post it formally. Look at the available answers: pure lame, or fake...
—SA

If a1 < b1 then the number is less than 0 so that's a case apart. If a1 > b2 then that's another case. Split those cases and create methods that solve each problem. For the first case you should take every fraction to its reduced form (no further division available, 1/2 is reduced but 2/4 is not). Take into account the modular difference of each pair when sorting.
 
Share this answer
 
Comments
nv3 14-Nov-13 10:37am    
"If a1 < b1 then the number is less than 0": you mean less than 1, don't you.
Arnaldo P. Castaño 14-Nov-13 10:47am    
yes sorry, I meant between 1 and 0.
Arnaldo P. Castaño 14-Nov-13 11:14am    
Let me know if my last solution was helpful
For the cases a/b (a
 
Share this answer
 
Comments
nv3 14-Nov-13 11:41am    
What's that?
Matt T Heffron 14-Nov-13 13:07pm    
In cases like this, don't post a new Solution, just use the Improve solution to fix it.
Sorry that last solution wasn't save correctly.

For the cases a/b where (a less than b) you could find the percentages that the fraction represents (without any need to reach a decimal) for instance 4/5 = 80%. This way you can order these type of fraction by percentages.
 
Share this answer
 
Comments
Stefan_Lang 15-Nov-13 6:12am    
Don't keep posting new solutions! Fix your existing solution by clicking the green "Improve Solution" link at the bottom right of your existing solution.

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