Console.WriteLine("请输入一个数字,会出现一个多边的菱形:"); int n = Convert.ToInt32(Console.ReadLine()); for (int i = 1; i <= n; i++) { for(int j=1;j<=n-i;j++) { Console.Write(" "); } for (int k = 1; k <= 2 * i - 1;k++ ) { Console.Write("*"); } Console.Write("\n"); } for (int o = 1; o <= n;o++) { for (int p = 1; p <= o;p++ ) { Console.Write(" "); } for(int q=1;q<=2*(n-o)-1;q++) { Console.Write("*"); } Console.Write("\n"); } Console.ReadLine();
时间: 2024-10-15 09:53:06