※狀況概述:
想做出可以出入數字印出這樣的結果如圖https://ibb.co/HthJK0H
目前只做到這樣https://ibb.co/9p4mKcx
試好久試不出來
請問大家要怎麼改呢
※程式碼:
import java.util.Scanner;
public class test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= (n - i); j++) {
System.out.print(" ");
}
for (int k = 1; k <= i; k++)
System.out.print("*");
System.out.println();
}
}
}
※錯誤訊息:
※補充說明: