C++中编程出现function does not take 1 parameters,求指正
#include<iostream>usingnamespacestd;typedefcharTElemType;constcharspace='^';constintM...
#include <iostream>
using namespace std;
typedef char TElemType;
const char space='^';
const int MAX_NODE_COUNT=20;
typedef struct BTreeNode
{
TElemType data;
struct BTreeNode *left ,*right;
}*Root;
class BTree
{
Root rt;
public:
BTree (){rt=NULL;}
void CreateBTree();
void DLRTraverse();
void LDRTraverse();
void LRDTraverse();
int depth();
};
void BTree::CreateBTree()
{
char value;
cin>>value;
if (value==space)
return;
rt=new BTreeNode;
rt->data=value;
BTree left,right;
left.CreateBTree();
right.CreateBTree();
rt->left=left.rt;
rt->right=right.rt;
}
void BTree::DLRTraverse()
{
if (rt)
{
BTree left,right;
left.rt=rt->left;
right.rt=rt->right;
cout<<rt->data;
left.DLRTraverse();
right.DLRTraverse();
}
}
void BTree::LDRTraverse()
{
if (rt)
{
BTree left,right;
left.rt=rt->left;
right.rt=rt->right;
left.LDRTraverse();
cout<<rt->data;
right.LDRTraverse();
}
}
void BTree::LRDTraverse()
{
if (rt)
{
BTree left,right;
left.rt=rt->left;
right.rt=rt->right;
left.LRDTraverse();
right.LRDTraverse();
cout<<rt->data;
}
}
int BTree::depth(rt)
{
int dep1,dep2;
if(rt==NULL) return 0;
else
{
dep1=depth(rt->left );
dep2=depth(rt->right );
return (dep1>dep2?(dep1+1):(dep2+1));
}
}
void main()
{
BTree T;
T.CreateBTree();
T.DLRTraverse();cout<<endl;
T.LDRTraverse();cout<<endl;
T.LRDTraverse();cout<<endl;
T.depth();cout<<endl;
} 展开
using namespace std;
typedef char TElemType;
const char space='^';
const int MAX_NODE_COUNT=20;
typedef struct BTreeNode
{
TElemType data;
struct BTreeNode *left ,*right;
}*Root;
class BTree
{
Root rt;
public:
BTree (){rt=NULL;}
void CreateBTree();
void DLRTraverse();
void LDRTraverse();
void LRDTraverse();
int depth();
};
void BTree::CreateBTree()
{
char value;
cin>>value;
if (value==space)
return;
rt=new BTreeNode;
rt->data=value;
BTree left,right;
left.CreateBTree();
right.CreateBTree();
rt->left=left.rt;
rt->right=right.rt;
}
void BTree::DLRTraverse()
{
if (rt)
{
BTree left,right;
left.rt=rt->left;
right.rt=rt->right;
cout<<rt->data;
left.DLRTraverse();
right.DLRTraverse();
}
}
void BTree::LDRTraverse()
{
if (rt)
{
BTree left,right;
left.rt=rt->left;
right.rt=rt->right;
left.LDRTraverse();
cout<<rt->data;
right.LDRTraverse();
}
}
void BTree::LRDTraverse()
{
if (rt)
{
BTree left,right;
left.rt=rt->left;
right.rt=rt->right;
left.LRDTraverse();
right.LRDTraverse();
cout<<rt->data;
}
}
int BTree::depth(rt)
{
int dep1,dep2;
if(rt==NULL) return 0;
else
{
dep1=depth(rt->left );
dep2=depth(rt->right );
return (dep1>dep2?(dep1+1):(dep2+1));
}
}
void main()
{
BTree T;
T.CreateBTree();
T.DLRTraverse();cout<<endl;
T.LDRTraverse();cout<<endl;
T.LRDTraverse();cout<<endl;
T.depth();cout<<endl;
} 展开
展开全部
好了,测试通过,请采纳
#include <iostream>
using namespace std;
typedef char TElemType;
const char space='^';
const int MAX_NODE_COUNT=20;
typedef struct BTreeNode
{
TElemType data;
struct BTreeNode *left ,*right;
}*Root;
class BTree
{
public:
Root rt;
public:
BTree (){rt=NULL;}
void CreateBTree();
void DLRTraverse();
void LDRTraverse();
void LRDTraverse();
int depth(Root);
};
void BTree::CreateBTree()
{
char value;
cin>>value;
if (value==space)
return;
rt=new BTreeNode;
rt->data=value;
BTree left,right;
left.CreateBTree();
right.CreateBTree();
rt->left=left.rt;
rt->right=right.rt;
}
void BTree::DLRTraverse()
{
if (rt)
{
BTree left,right;
left.rt=rt->left;
right.rt=rt->right;
cout<<rt->data;
left.DLRTraverse();
right.DLRTraverse();
}
}
void BTree::LDRTraverse()
{
if (rt)
{
BTree left,right;
left.rt=rt->left;
right.rt=rt->right;
left.LDRTraverse();
cout<<rt->data;
right.LDRTraverse();
}
}
void BTree::LRDTraverse()
{
if (rt)
{
BTree left,right;
left.rt=rt->left;
right.rt=rt->right;
left.LRDTraverse();
right.LRDTraverse();
cout<<rt->data;
}
}
int BTree::depth(Root rt)
{
int dep1,dep2;
if(rt==NULL) return 0;
else
{
dep1=depth(rt->left );
dep2=depth(rt->right );
return (dep1>dep2?(dep1+1):(dep2+1));
}
}
void main()
{
BTree T;
T.CreateBTree();
T.DLRTraverse();cout<<endl;
T.LDRTraverse();cout<<endl;
T.LRDTraverse();cout<<endl;
cout<<T.depth(T.rt);cout<<endl;
}
帕剌斯
2024-10-29 广告
2024-10-29 广告
德国Palas 成立于1983年,总部位于德国巴登符腾堡州的卡尔斯鲁厄。作为气溶胶技术专家, Palas 致力于为用户提供气溶胶颗粒物的产生、处理、测量与分析解决方案,是该领域内全球先进的开发商和制造商。基于自身技术的独特优势,Palas ...
点击进入详情页
本回答由帕剌斯提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询