20161009随笔

今日内容主要讲述了for的循环以及if的嵌套与应用 讲述了左三角、右三角的变化过程。

 //Console.WriteLine(sum);             //Console.ReadLine();             //兔子对数。             //本月的成兔=上月的小兔+上月的成兔             //本月的小兔=上月的小兔             //本月的幼兔=本月的成兔             //Console.WriteLine("请输入月份:");             //int m = int.Parse(Console.ReadLine());             //int yt=0;//计算幼兔的数量值             //int xt=0;//计算小兔的数量值             //int ct=0;//计算成兔的数量值             //for (int i = 1; i <= m; i++)             //{             //    if (i == 1)             //    {             //        yt = 1;             //        ct = 0;             //        xt = 0;                                 //    }             //    else             //    { ct = xt +ct;             //        xt =yt ;             //        yt = ct;                                                //    Console.WriteLine("第{0}个月的幼兔数量为{1}", i, yt);             //    Console.WriteLine("第{0}个月的小兔数量为{1}", i, xt);             //    Console.WriteLine("第{0}个月的成兔数量为{1}", i, ct);             //    }             //}             //求100以内的质数:             int sum = 0;             for (int i = 2; i <= 100; i++)             {                 if (i%2!=0&&i%3!=0&&i%5!=0&&i%7!=0)                 {                     sum += i;                 }                             }

                 Console.WriteLine(sum+2+3+5+7);

                Console.ReadLine();

posted on 2016-10-09 19:53  sdutlyy  阅读(151)  评论(0)    收藏  举报