You noticed that the height of the triangle is 2 ^ n, I'm sure. So you need to print a lot of lines. You also know that you need to remember the previous lines if you are going to copy them somehow, so you know that you need to store them somewhere - perhaps Vector?
, , , . , , , - .
, "*": .
"n" :
. , , .
(, , , , for . , . , , , [ ] .)
. padRight n, . padLeft, , :
public static String padRight(String s, int n) {
return String.format("%1$-" + n + "s", s);
}
public static String padLeft(String s, int n) {
return String.format("%1$#" + n + "s", s);
}
: , .