• 例题;假设一张纸厚度为0.001米,对折多少次高度可以超过珠峰高度(8848)米。一个篮球第二次弹起的高度是第一次弹起高度的2/3,问弹起n次以后的高度是多少。 主要学习for循环


    对折纸的例题:
                double houdu = 0.001;
                for (int i = 1; 1==1; i++)
                {
                    houdu = houdu + houdu;
                    Console.WriteLine("第"+i+"次对折后纸的厚度为"+houdu+"米" );
                    if (houdu >=8848)
                    {
                        break;
                    }
             
                }
                Console.ReadLine();

    篮球弹起的题:

                Console.WriteLine("请输入求第一次谈起的高度");

                double n = Convert.ToInt32(Console.ReadLine());

                for (int i = 1; 1 == 1; i++)

                {

                    n = n * (2.0 / 3.0);

                    Console.WriteLine("第" + i + "次篮球弹起的高度为:" + n);

                    if (n < 0.001)

                    {

                        break;

                    }

                }            

    Console.ReadLine();

  • 相关阅读:
    2016百度之星资格赛 Problem B(大数+组合数)
    HDU 4380 Farmer Greedy(叉积和三角形知识的综合应用)
    C++ STL (备忘)
    【Linked List Cycle II】cpp
    【Linked List Cycle】cpp
    【Copy List with Random Pointer】cpp
    【Reverse Nodes in k-Group】cpp
    【Swap Nodes in Pairs】cpp
    【Remove Nth Node From End of List】cpp
    【Rotate List】cpp
  • 原文地址:https://www.cnblogs.com/275147378abc/p/4428505.html
Copyright © 2020-2023  润新知