利用for循环的嵌套输出图形--课后作业

for (int i = 1; i <= 8; i++)
            {
                int a, b;
                for (a = 1; a < i; a++)
                    Console.Write(" ");
                for (b = 8; b >= i; --b)
                    Console.Write("*");
                Console.WriteLine();
            }
            Console.ReadLine();

  作业一得到的是这个图形

for (int i = 1; i <= 8; i++)
            {
                int a, b, c;
                for (a = 8; a > i; a--)
                    Console.Write(" ");
                for (b = 1; b <= i; b++)
                    Console.Write("*");
                for (c = 1; c < i; c++)
                    Console.Write("*");
                Console.WriteLine();
            }
            for (int i = 1; i <= 7; i++)
            {
                int a, b, c;
                for (a = 1; a <= i; a++)
                    Console.Write(" ");
                for (b = 7; b >= i; b--)
                    Console.Write("*");
                for (c = 7; c > i; --c)
                    Console.Write("*");
                Console.WriteLine();
            }
            Console.ReadLine();

  作业二得到的是这个图形

posted @ 2015-08-03 21:42  WhyToHow  阅读(2338)  评论(0编辑  收藏  举报