需要有关如何查找丢失号码的帮助? [英] Need help on how to find missing numbers?

查看:102
本文介绍了需要有关如何查找丢失号码的帮助?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个任务,例如,如果有一个数字85.88,第二个数字是0.22。我如何减去0.22并将其加到85.88,使其正好转为86,第二个值转为0.10?

(我需要知道如何为不同的值执行此操作,如:22.15和0.99 .. 。等等)



我的尝试:



一切在我的脑海里

I got a task, for example if there is a number 85.88 and the second number is 0.22. How do i subtract 0.22 and add it to 85.88 so that it turns exactly 86 and the second value turns 0.10?
(I need to know how to do it for different values like: 22.15 and 0.99... and so on)

What I have tried:

Everything that was in my mind

推荐答案

虽然问题陈述不明确。



我想你想要的确定调整数字以使分数变满。



1.首先使用math.round()来获得所需的圆形数字(86)。

2.然后减去圆形数字(86)和实际数字(85.88)得到第二个数字(.22)



以上步骤你可以找到第二个实现圆形数字的任何分数的数字(通常在最终总数之前放入账单以显示调整后的数量)
Although problem statement is not clear stated.

I think you want to determine adjustment figure to make fraction full.

1. First use math.round() to get to get desired rounded figure (86).
2. then Subtract rounded figure(86) and actual figure(85.88) to get second figure(.22)

with above steps you can find out second figure of any fraction to achieve the rounded figure ( generally put in bills before final total to show adjusted amount )


对于一般问题没有解决方案。

在第一种情况下( 85.88 0.22 )你很幸运: 0.12 诀窍。

另一方面手,我看不到secondo case的解决方案( 22.15 0.99 )。
There is not a solution for the general problem.
In the first case (85.88 and 0.22) you are lucky: 0.12 does the trick.
On the other hand, I cannot see a solution for secondo case (22.15 and 0.99).


听起来你正试图取较高的数字并将其向上增加到最接近的整数,然后从较小的数字中减去相同的数量。



例如:

84.75和0.32会给你84.75 + .25和0.32 - 0.25,这反过来会得到85和0.07。



如果是这种情况,您可以执行以下操作:



It sounds like you're trying to take the higher number and increase it upward to the nearest integer and then subtract that same amount from the smaller number.

Example:
84.75 and 0.32 would give you 84.75 + .25 and 0.32 - 0.25, which in turn gets you 85 and 0.07.

If that's the case, you could do the following:

double highNum = 84.75; // Or any other first number
double lowNum = 0.32; // or any other second number
double newHighNum = Math.Ceiling(highNum);
double newLowNum = lowNum - (newHighNum - highNum);

Console.WriteLine(


这篇关于需要有关如何查找丢失号码的帮助?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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