| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 980 人关注过本帖
标题:请教大家一个问题
取消只看楼主 加入收藏
yuxudaoren
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2006-3-24
收藏
 问题点数:0 回复次数:6 
请教大家一个问题

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.

上面要求的将树载入内存可否看做是树的存储呢 这样定义一个结点类用左孩子——右兄弟的方法可以么? 谢谢~~~

搜索更多相关主题的帖子: following beginning represents 
2006-03-24 01:30
yuxudaoren
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2006-3-24
收藏
得分:0 
回复everajax
因为这个是树的存储 所以应该不用考虑树结点的插入和移动吧 我对vector这个不熟悉 能具体给出题中要求的树的栽入的实现部分么? 谢谢
2006-03-24 10:18
yuxudaoren
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2006-3-24
收藏
得分:0 

用c++就可以了 谢谢这位大侠

2006-03-24 18:18
yuxudaoren
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2006-3-24
收藏
得分:0 
回复:(everajax)没作太仔细的error handling,如果...
刚刚看到大侠给写的代码,调试了一下,只显示press any key to continue    改了改还是不行 请帮忙看看  谢谢!~~
2006-03-25 23:04
yuxudaoren
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2006-3-24
收藏
得分:0 
回复:(everajax)只认识TAB(\t)用空格是不行的,试试...
谢谢哥哥的回复  附件只是一个树型文件啊  如何操作  是把这个文件添加到代码里么?
2006-03-26 10:03
yuxudaoren
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2006-3-24
收藏
得分:0 
回复:(everajax)附件是所存储的树的格式。把它更名...

这回完全搞定 谢谢哥哥的帮忙 能留个QQ号么 以后好多多请教 谢谢!~~

2006-03-26 14:36
yuxudaoren
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2006-3-24
收藏
得分:0 
回复:(everajax)没有QQ。就在这联系8。
呵呵 好的 以后还请多多帮忙  
2006-03-26 15:06
快速回复:请教大家一个问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012369 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved