サイズ制限が20文字(正方形のサイズ)の正方形のASCIIを描画する際に問題があります。これは私のコードです。テストしましたが動作しますが、 20以上のそれはエラーを表示している、plsの助け、ありがとう。Javaを使用したASCIIアートの描画
class Main {
public static void printSquare(int size) {
int line = 1;
while (line <= size) { // For each line of square
int width = size; // width of square segment
int i = 1; // display square segment
while (i <= width && size <= 20) {
System.out.print("*");
i = i + 1;
}
System.out.println(); // Newline
line = line + 1;
}
}
}
あなたが得るエラーは何ですか? – Marcus