我很難搞清楚java賦值中的最後一個模式。我知道我很接近,但我想不出它在這裏是我的代碼:使用嵌套循環在java中製作模式
public static void main(String[]args){
System.out.println("Pattern D:");
for (int i = 6; i>=1; i--) { // row
int x = 6; // Counter?
for (int j = 1; j<=i; j++){ //column
System.out.print("");
x--;
}
for(int k=1;k<=i;k++) {
System.out.print(x);
}
System.out.println();
}
}
據我所知,外環是行內的列,但是這不是我有錯的部分。我自己的模式是正確的,但不是數字的輸出。 我不能把我的輸出放在這裏,因爲它不會格式正確。但是,如果你完全複製我的代碼而不是一行0,然後1,然後,2 ...等,我試圖在頂線上獲得1 2 3 4 5 6,然後1 2 3 4 5,下一行等...
啊,實際上改變了格局。我想我搞砸了我的意思。我試圖得到的模式是正確的完整的通過頂部的6行。 – Kevin 2014-12-06 02:48:57
是否所有的數字都需要定位在右側,還是我缺少更多? – ejmejm 2014-12-06 02:50:50
老實說,我只是自己想出來的,但是是的,這是對的。我對這個糟糕的解釋表示歉意。我會發布我的解決方案 – Kevin 2014-12-06 02:58:40