Console-算法[for,if]-一一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在

ylbtech-Arithmetic:Console-算法[for,if]-一 一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?
 
1.A,Demo(案例)

 一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在
   第10次落地时,共经过多少米?第10次反弹多高?

1.B,Solution(解决方案)
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            float sn = 100f;
            float hn = sn / 2;
            for (int n = 2; n <= 10; n++)
            {
                sn = sn + 2 * hn;   //第n次落地时共经过的米数
                hn = hn / 2;        //第n次反跳高度
            }
            Console.WriteLine("The total of road is {0}",sn);
            Console.WriteLine("The tenth is {0} meter",hn);
        }
    }
}
1.C,Execution Result(运行结果)
The total of road is 299.6094
The tenth is 0.09765625 meter
请按任意键继续. . .
warn 作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
posted on 2013-05-06 15:31  ylbtech  阅读(5558)  评论(0编辑  收藏  举报