You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to EnJoyJava
import java.util.Scanner;
class Text {
public static void main(String arg[]) {
Scanner in = new Scanner(System.in);
System.out.println("請輸入高度");
int high = in.nextInt();
System.out.println("請輸入階數");
int level = in.nextInt();
for (int i = 0; i < level; i++) {
for (int j = 1; j < high+1; j++) {
for (int k = 0; k < (level-i)+(high-j); k++) {
System.out.print(" ");
}
for (int o = 1; o < (j*2)+(i*2); o++) {
System.out.print("*");
}
System.out.println();
}
}
for (int i=0; i<3; i++) {
for (int k = 0; k < (level+high)-2; k++) {
System.out.print(" ");
}
for (int j = 0; j < 3; j++) {
System.out.print("*");
}
System.out.println();
}
}
}