码迷,mamicode.com
首页 > 其他好文 > 详细

迭代法 丢羊了

时间:2015-04-02 20:33:28      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:

 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();
        }

迭代法 丢羊了

标签:

原文地址:http://www.cnblogs.com/lk-kk/p/4388098.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!