迭代法 丢羊了

时间:2015-04-02 20:33:28   收藏:0   阅读:104

 static void Main(string[] args)
        {
            int y = 2;                                   //过一个村庄丢一半零一只,过了7个村庄还是2只,求原来几只
            for (int i = 1; i <=7; i++)
            {
                y = (y + 1) * 2;
            }
            Console.WriteLine(y);
            Console.ReadLine();
        }

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!