最近学习c++,越看越觉得以前所学只是皮毛.这几天正好有空闲就写点小算法玩玩.
多叉树的层次遍历 这个在网上有完整程序的好像不多.这次我就把写的贴出来,
有兴趣的朋友一起来研究下.
TreeNode.h 文件
#ifndef __TREENODE_
#define __TREENODE_
#include "StdAfx.h"
#include <string>
#include <list>
#include <iostream>
#include <queue>
using namespace std;
class TreeNode
{
private:
long selfID;
string nodeName;
list<TreeNode*> *p_childList;
public:
TreeNode();
~TreeNode();
/*向当前节点中插入一个子节点*/
void insertChildNode(TreeNode *treeNode);
/*遍历树,层次遍历*/
void LevelTraverse() ;
多叉树的层次遍历 这个在网上有完整程序的好像不多.这次我就把写的贴出来,
有兴趣的朋友一起来研究下.
TreeNode.h 文件
#ifndef __TREENODE_
#define __TREENODE_
#include "StdAfx.h"
#include <string>
#include <list>
#include <iostream>
#include <queue>
using namespace std;
class TreeNode
{
private:
long selfID;
string nodeName;
list<TreeNode*> *p_childList;
public:
TreeNode();
~TreeNode();
/*向当前节点中插入一个子节点*/
void insertChildNode(TreeNode *treeNode);
/*遍历树,层次遍历*/
void LevelTraverse() ;