import java.util.Scanner;
class San_Jiao_Shu1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个整数");file:///C:\Users\DELL\AppData\Roaming\Tencent\Users\763495653\QQ\WinTemp\RichOle\0)0V~8$YUFB)X1S)L$1F5YK.pngfile:///C:\Users\DELL\AppData\Roaming\Tencent\Users\763495653\QQ\WinTemp\RichOle\0)0V~8$YUFB)X1S)L$1F5YK.png
int n = sc.nextInt();
for (int i = 1; i <=n; i++) {
for (int j = i; j <=n; j++) {
System.out.print(" ");
}
for (int z = 1;z <= i; z++) { //先打印杨辉三角
System.out.print("* ");
}
System.out.println();
}
for (int i =1;i<=n ;i++ ) {
for (int j = 1;j<=n ;j++ ) {
System.out.print(" "); //在打印下面的树干
}
System.out.print("*");
System.out.println();
}
System.out.println();
}
}
|
|