#include<iostream>
#include<string>
#define MaxSize 5
using namespace std;
class BiTree
{
public:
BiTree();
void leverOrder();
static int count;
private:
string array[100];
};
int BiTree::count=1;
BiTree::BiTree()
{
for(int i = 0;i < MaxSize;i++)
{
array[i] = '#';
}
string value;
for(int j=1;j<MaxSize;j++)
{
cout<<"输入结点:";
cin>>value;
array[j] = value;
count++;
}
}
void BiTree::leverOrder()
{
for(int i = 1;i < BiTree::count;i++)
{
cout<<array[i]<<" ";
cout<<endl;
}
}
int main()
{
cout<<"*****创建一棵二叉树(顺序存储)*****"<<endl<<endl;
cout<<"@@@层序输入"<<endl<<endl;
BiTree Tree;
cout<<endl;
cout<<"层序输出:"<<endl;
Tree.leverOrder();
cout<<endl;
return 0;
#include<string>
#define MaxSize 5
using namespace std;
class BiTree
{
public:
BiTree();
void leverOrder();
static int count;
private:
string array[100];
};
int BiTree::count=1;
BiTree::BiTree()
{
for(int i = 0;i < MaxSize;i++)
{
array[i] = '#';
}
string value;
for(int j=1;j<MaxSize;j++)
{
cout<<"输入结点:";
cin>>value;
array[j] = value;
count++;
}
}
void BiTree::leverOrder()
{
for(int i = 1;i < BiTree::count;i++)
{
cout<<array[i]<<" ";
cout<<endl;
}
}
int main()
{
cout<<"*****创建一棵二叉树(顺序存储)*****"<<endl<<endl;
cout<<"@@@层序输入"<<endl<<endl;
BiTree Tree;
cout<<endl;
cout<<"层序输出:"<<endl;
Tree.leverOrder();
cout<<endl;
return 0;
}