日期:2014-05-20 浏览次数:20740 次
static List<String[]> list=new ArrayList<String[]>(); static { list.add(new String[]{"1","0","A"}); list.add(new String[]{"2","1","B"}); list.add(new String[]{"3","1","C"}); list.add(new String[]{"4","2","D"}); list.add(new String[]{"5","3","E"}); list.add(new String[]{"6","5","F"}); list.add(new String[]{"7","0","G"}); list.add(new String[]{"8","7","H"}); list.add(new String[]{"9","3","I"}); } public static void test(String n,int lvl){ String p=""; for(int i=1;i<lvl;i++){ p+="---"; } for(String[] d:list){ if(d[1].equals(n)){ System.out.println(p+d[0]+"--"+d[2]); test(d[0],(lvl+1)); } } } public static void main(String[] args) { test("0",1); }