如何製作一個程序,提示用戶輸入行數和列數,並輸出類似空心矩形(使用「*」)的圖形,這些行和列使用while循環形成?JAVA while while循環
Scanner stdin = new Scanner(System.in);
System.out.println("Enter number of rows and columns: ");
int row = stdin.nextInt();
int column = stdin.nextInt();
int m = 1;
while(m <= column)
{
while(m <= row)
{
System.out.println("*\t");
}
System.out.print("*");
m++;
}
你做到了已經。你現在的問題是什麼? –
只要'row> 1',你的innerloop將永遠運行。不要在內部循環中使用與外部循環相同的變量。 – CollinD
@CollinD我不明白我的內循環如何永遠運行 –