Java Lösung
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | public class Weihnachtsbaum
{
public static void draw(int reihen)
{
int offset = reihen*4;
String out = "";
for(int ast=0; ast<reihen; ast++)
{
for(int zweig=0; zweig<3; zweig++)
{
out += multip(" ", offset-2*zweig)+multip("*",((2*zweig)+(ast*3)))+"|"+multip("*",((2*zweig)+(ast*3)))+"\n";
}
offset-=3;
}
out+= multip(" ", (reihen*4)-2)+"|"+multip(" ", 3)+"|";
System.out.println(out);
}
private static String multip(String str, int n)
{
String out = "";
for(int i=0; i<n; i++)
out+=str;
return out;
}
}
|
erstellt am 2.12.2008 20:55, zuletzt gendert am 2.12.2008 21:04
