Вероятно, вы видели это раньше в классе Java 1: это проблема, которая просит вас написать программу, которая рисует следующий рисунок:
Мне нужно использовать константу. Мне не разрешено использовать ничего, кроме for-loops, print
и println
. Нет параметров, нет массивов. Я знаю, как это сделать с параметрами и массивами, мне повезло. Любая помощь приветствуется!
Вот мой неполный код:
public class Stairs {
public static final int LENGTH=5;
public static void main(String[] args) {
printStairs();
}
public static void printStairs() {
for (int allStairs=1; allStairs<=15; allStairs++) {
for (int spaces=1; spaces<=(-5*allStairs+30); spaces++) {
System.out.print(" ");
}
for (int stair = 1; stair <= 5; stair++) {
System.out.println(" o *******");
}
}
}
}