分数分类 [英] sorting of fraction numbers

查看:99
本文介绍了分数分类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1 / 3,2 / 5,4 / 7,.....

如果不将元素转换为小数,请对它们进行排序。

提示:处理a1 / b1为(a1,b1)作为一对数字。和a1

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

推荐答案

如果a1< b1然后这个数字小于0,所以这是一个案例。如果a1>那么这是另一种情况。拆分这些案例并创建解决每个问题的方法。对于第一种情况,你应该把每一部分都缩小到它的缩小形式(没有进一步的除法,1/2减少,但2/4不是)。在排序时考虑每对的模块差异。
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.


对于案例a / b(a
For the cases a/b (a


抱歉最后的解决方案没有保存正确。



对于案例a / b,其中(小于b)你可以找到分数所代表的百分比(不需要达到小数)实例4/5 = 80%。这样您可以按百分比订购这些类型的分数。
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.


这篇关于分数分类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆