このプログラムを完了するのに苦労しています。アスタリスクを作成するプログラムを作成しようとしていますが、それを三角形にします。
これは私がすでに持っているものです。
public class 12345 {
public static void main(String[] args) {
int n = 0;
int spaces = n;
int ast;
System.out.println("Please enter a number from 1 - 50 and I will draw a triangle with these *");
Scanner keyboard = new Scanner(System.in);
n = keyboard.nextInt();
for (int i = 0; i < n; i++) {
ast = 2 * i + 1;
for (int j = 1; j <= spaces + ast; j++) {
if (j <= spaces)
System.out.print(' ');
else
System.out.print('*');
}
System.out.println();
spaces--;
}
}
}
アスタリスクを作成していますが、三角形を作る場所でそれらを続けるにはどうすればよいでしょうか...それらは進むにつれて大きくなり、次に小さくなります...
前もって感謝します!