青蛙跳井的故事

从前有一只青蛙,它掉进了井中,从此开始了它的求生之路。。。

青蛙掉进了10米的井中,每天上午向上跳3米,下午会往下掉2米,求第几天能出井?

            int jing = 10;
            int a = 0;
            for (int v = 0; a < jing;v++ )
            {
                a += 3;
                  Console.WriteLine("上午" + a);
                a -=  2;
                   Console.WriteLine("下午" + a);
                   Console.WriteLine("------------");
                if (a >= 10)
                {
                    Console.WriteLine(v);
                }
            }
            Console.ReadLine();
展开代码

若有错误,愿园友不吝赐教!

posted @ 2015-06-25 20:28  IT火  阅读(850)  评论(0编辑  收藏  举报