all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
parent b83f433714
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -0,0 +1,27 @@
import java.util.*;
public class Sierpinski
{
public static List<String> sierpinski(int n)
{
List<String> down = Arrays.asList("*");
String space = " ";
for (int i = 0; i < n; i++) {
List<String> newDown = new ArrayList<String>();
for (String x : down)
newDown.add(space + x + space);
for (String x : down)
newDown.add(x + " " + x);
down = newDown;
space += space;
}
return down;
}
public static void main(String[] args)
{
for (String x : sierpinski(4))
System.out.println(x);
}
}