このプログラムを完了するのは難しいです。私はアステリックスを作成するプログラムを作ろうとしていますが、それを三角形にしています。Javaでの初心者 - 出力の制御 - Asterixの生成
これは私がすでに持っているものです。
...感謝をそれはasteriksを作成しているが、どのように私は、彼らが三角形を作る場所にそれらを継続することができるでしょう...そう、彼らが行くように、彼らは大きなを取得した後、戻って小さな
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--;
}
}
}
あなたは事前に!
番号で始まるクラス名は許可されていますか? – Shekhar
菱形のような構造にしたいですか? – vikiiii
は「直角三角形」を作成することから始まります。 – Azodious