• 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/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    hdoj1251 统计难题 字典树
    nyoj322 sort 归并排序,树状数组
    优先队列 如何使用
    字典树(讲解+模版)
    hdoj1069 Monkey and Banana
    ny10 skilng
    hdoj1075 What Are You Talking About
    hdoj1171 Big Event in HDU
    ny613 免费馅饼
    Spring Boot2.0之Admin-UI分布式微服务监控中心
  • 原文地址:https://www.cnblogs.com/ylbtech/p/3062889.html
Copyright © 2020-2023  润新知