2.用一层循环打印99乘法口诀表

            #region 2、用一层循环打印九九乘法口诀。

            #region 方法1

            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= i; j++)
                {
                    Console.Write("{0}*{1}={2}", j, i, i * j);
                }
                Console.WriteLine("");
            }
            Console.ReadLine();
            #endregion

            #region 方法2

            //for (int i = 0; i < 81; i++)
            //{
            //    int x = i % 9 + 1;
            //    int y = i / 9 + 1;
            //    if (x > y)
            //        continue;

            //    Console.Write("{0}*{1}={2} ", x, y, x * y);

            //    if (x == y)
            //        Console.WriteLine("");
            //}
            #endregion
            #endregion

 

posted @ 2013-09-04 17:35  LifeForCodes  阅读(289)  评论(0编辑  收藏  举报