ITeye博客

模拟树结构读取

Narnia08 · 2009-03-21 20:20 · 数据结构 · Markdown

模拟树结构读取

public class Test {

/**
 * @param args
 */
public static void main(String args)
{
    //树结构数据
    String str = new String
    {
        { "1", "0", "ss" },
        { "2", "1", "ss" },
        { "3", "1", "ss" },
        { "4", "1", "ss" },
        { "5", "2", "ss" },
        { "6", "2", "ss" },
        { "7", "3", "ss" },
        { "8", "3", "ss" },
        { "9", "3", "ss" },
        { "10", "5", "ss" },
        { "11", "5", "ss" },
        { "12", "5", "ss" },
    };
    readTree(str, "1");

}

public static  void readTree(String str,String father)
{
    for (int i = 0; i < str.length; i++)
    {
        if(str*.equals(father))
        {
            System.out.println(str*+" | "+str*);
            //递归调用
            readTree(str, str*);
        }
    }

}

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。