文章
79
粉丝
221
获赞
46
访问
196.6k
#include <iostream>
#include <string>
#include <stack>
using namespace std;
typedef struct Node {
char data;
struct Node* left, * right;
int fl = 0, fr = 0;
}Node, * Tree;
void PreOrder(Tree T) {
if (T) {
cout << T->data << " ";
PreOrder(T->left);
PreOrder(T->right);
}
}
void InOrder(Tree T) {
if (T) {
InOrder(T->left);
cout << T->data << " ";
InOrder(T->right);
}
}
void BeOrder(Tree T) {
if (T) {
BeOrder(T->left);
BeOrder(T->right);
cout << T->data << " ";
}
}
void StOrder(Tree T) {
stack <Node*> st;
st.push(T);
while (!st.empty()) {
Node* p = st.top();
cout << p->data << " ";
st.pop();
if (p->left)
st.push(p->left);
if(p->right)
st.push(p->right);
}
}
void Cou(Tree T,int &res) {
if (T) {
Cou(T->left,res);
Cou(T->right,res);
if (!T->left && !T-&g...
登录后发布评论
暂无评论,来抢沙发