桃心代码

Console.WriteLine("请问你需要多大的桃心:");
            int a = Convert.ToInt32(Console.ReadLine());
            if (a % 2 == 1) { a += 1; }
            int x = a / 2;
            for (int i = x / 2; i < a; i++)
            {
                for (int j = 1; j < a; j++)
                {
                    if (((i + j == x + 1 || j - i == x - 1) || (i == j || i + j == a)) && i > x / 2 && i <= x) { Console.Write((char)3+" "); }
                    else if (i - j == x - 1 || j + i == 3 * x - 1)
                    {
                        Console.Write((char)3 + " ");
                    }
                    else
                    {
                        Console.Write("  ");
                    }
                }
                Console.WriteLine();
            }

            Console.WriteLine("\n");

            int y = a / 4;
            for (int i = 1; i < a; i++)
            {
                for (int j = 1; j < a; j++)
                {
                    if (((j > y - i && j <= y + i - 1) || (j > 3 * y - i && j <= 3 * y + i - 1)) && i <= y + 1)
                    {
                        if (i == 1 && (j == y || j == 3 * y)) { Console.Write("  "); }
                        else { Console.Write((char)3 + " "); }
                    }
                    else if (i > y + 1 && (j < a - i + y + 6 && j > i - y - 6)) { Console.Write((char)3+" "); }

                    else { Console.Write("  "); }
                }
                Console.WriteLine();
            }

作者: Mr_wen   发布时间: 2011-06-03