我被困在使用for-loop的第二行結尾的符號上,我曾嘗試過幾次,但仍然無法工作。有人能告訴我我做錯了嗎?如何在Java中使用for-loop打印出由符號製作的圖像?
////////////////\\\\\\\\\\\\\\\\
////////////********
////////****************
////************************
********************************
它假設是這個樣子:
////////////////\\\\\\\\\\\\\\\\
////////////********\\\\\\\\\\\\
////////****************\\\\\\\\
////************************\\\\
********************************
這裏是我的代碼:
public static void main (String [] args){
for (int lineOne=1; lineOne<=16; lineOne += 2){
System.out.print("//");
}
for (int lineOne=1; lineOne<=32; lineOne += 2){
System.out.print("\\");
}
System.out.println("");
for (int a=8; a<=32; a += 8)
{
for (int b=12; b < (28 - a/2); b +=2)
{
System.out.print("//");
}
for (int c=0; c<a; c++)
{
System.out.print("*");
}
System.out.println("");
}
}
沒想到這一次通過,沒有你。 –
打印完'*'後,您不打印任何'\'? – Blorgbeard
如果你已經做到了這一點,你可以做到。有耐心和運用你的邏輯。 – Reji