|
引用第0楼樱雪于2006-10-22 17:28发表的“一个数学问题”:
一个布店卖布,布是49.36一米,账簿看不清楚了,卖了多少米不知道,只知道是整数,而且卖出的布的总额的前两个数也看不清了,只看到后面是7.28,问卖了几米布
布价尾数为6,6只有与3及8乘能得到8,又因为总额只有前两个数看不清,那总额应小于1000,姑且从3到100之间来试吧:- /// <summary>
- /// Here is the C# code to resolve this problem.
- /// </summary>
- static void Main(string[] args)
- {
- string totalMoney = "";
- for(int theLength=3;theLength<100;theLength+=5)
- {
- totalMoney = (theLength * 49.36).ToString();
- if ( totalMoney.EndsWith("7.28"))
- {
- Console.WriteLine("The length maybe is {0} meters,and the income is {1}", theLength, totalMoney);
- }
- }
- }
复制代码
结果出来了,The length maybe is 98 meters,and the income is 4837.28
看来题目稍有点问题,总额小数点前不止三位。那么加大查找范围,在一千以内计算,结果为The length maybe is 223 meters,and the income is 11007.28
The length maybe is 348 meters,and the income is 17177.28
The length maybe is 473 meters,and the income is 23347.28
The length maybe is 598 meters,and the income is 29517.28
The length maybe is 723 meters,and the income is 35687.28
The length maybe is 848 meters,and the income is 41857.28
The length maybe is 973 meters,and the income is 48027.28
回答完毕!
觉得算得好的,请送花吧,嘿嘿
[s:40] [s:69] |
|