package com.gem.homework;
import java.util.Scanner;
public class T8Tower {
public static void main(String[] args) {
// TODO Auto-generated method stub
int num;
Scanner scan = new Scanner(System.in);
System.out.println("请输入塔层数 : ");
num = scan.nextInt();
for (int line = 0; line < num; line++) {
for(int row = 0;row < num - line - 1;row++){
System.out.print(" ");
}
for(int row = 0;row <= line;row++){
System.out.print("*" + " ");
}
System.out.println();
}
for (int line = 0; line < num; line++) {
for(int row = 0;row <= line;row++){
System.out.print(" ");
}
for(int row = 0;row < num - line - 1;row++){
System.out.print("*" + " ");
}
System.out.println();
}
}
}
金字塔
最新推荐文章于 2022-08-15 22:47:38 发布