Я пытаюсь понять, почему мой бриллиант не полностью формируется внизу. Когда пользователь вводит какое-либо нечетное число больше трех, алмаз неправильно формируется внизу (он печатает только одну строку после самой большой средней линии). Похоже, что это (я пробовал пять строк для данного примера):Как сформировать алмаз в Java
*
* *
* * *
* *
Я считаю, что что-то не так с для петель, которые, как предполагается создать в нижней части алмаза. Код для этого:
//bottom of the diamond
for(j = (in + 1)/2; j < in; j++){ //similar to the first for statement instead when j equals the user's input plus one divided by two it will then go to the next for loop (the diamond starts to shrink)
for(i = 1; i < j; i++){ //when i equals one, and j is greater than one
System.out.print(" "); //prints space
}
for(l = 0; l < in - j; j++){ //similar to the for loop that prints the asterisk to the left this for loop goes through when l equals zero, and this time is less than the user's input minus j
System.out.print(" *"); //prints the bottom asterisks
}
System.out.println(""); //starts another blank new line
} //just like the top section it keeps looping until the requirements are no longer met
Что я делаю неправильно?
'l = 0; l
Спасибо за исправление (удивлен, что я пропустил эту опечатку)! – Fyree