1 条题解
-
0
Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner n = new Scanner(System.in); int a = n.nextInt(); int i = 1, k = 0, y = 0; if (a < 10) { while (i <= a) { k = (a - i) * 2; while (k > 0) { System.out.print(" "); k--; } y = 0; while (i > 0) { System.out.print(i + " "); i--; y++; } i += 2; while (i <= y) { System.out.print(i + " "); i++; } System.out.print("\n"); } } else { int b = a - 9; while (i <= 9) { k = (9 - i) * 2 + b * 3; while (k > 0) { System.out.print(" "); k--; } y = 0; while (i > 0) { System.out.print(i); System.out.print(" "); i--; y++; } i += 2; while (i <= y) { System.out.print(i); System.out.print(" "); i++; } System.out.print("\n"); } b = a - 10; while (i <= a) { k = (a - i) * 2 + b; while (k > 0) { System.out.print(" "); k--; } b--; y = 0; while (i > 0) { System.out.print(i); System.out.print(" "); i--; y++; } i += 2; while (i <= y) { System.out.print(i); System.out.print(" "); i++; } System.out.print("\n"); } } } }
- 1
信息
- ID
- 3361
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者