LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 769|回复: 1

哪位大侠有时间帮小弟写个程序啊 急 谢谢!~~

[复制链接]
发表于 2006-3-20 00:33:19 | 显示全部楼层 |阅读模式
The following represents a sample tree saved in a file.
The children of each node has an extra '\t'
at the beginning and the children of each
node are directly under it.
The tree can be very deep and each node can have 0 to many child nodes.
===========================
Root
         V:\
                       FolderX
                                   FolderA1
                                   FolderD2
                       FolderB
                                   FolderW1
                                   FolderB2
         D:\
                       FolderM
                                   FolderQ1
                                   FolderC2
============================

Please implement a program to load the whole tree into the memory from the tree file.  The program should not only load the tree file above, but also load other similar tree files.

The tree data structure should be similar as.
Class Tree
{
         string name;
         int     level;  // the depth of the node from the root
         Array          children; // each object in the Array is the type Tree.
}

And then sort the child nodes of each node in the ascending order using IComparer interface.
Then print the tree out in the same tree file format.
发表于 2006-3-20 08:06:50 | 显示全部楼层
maybe,your class tree must like:
Class Tree
{
string name;
int level;
Array children;
Tree parent;
}
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表