文章
35
粉丝
599
获赞
6
访问
311.7k
如果不写删除函数的话会超时,
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
using namespace std;
//const int maxn=110;
struct node{
char data;
struct node* lchild;
struct node* rchild;
};//为什么我不定义变量直接用node不行
//node* pre[maxn],in[maxn];
int pos;
string s;
//node* tree;
//void create(node* &tree){
void create(node* &tree){
if(pos>=s.size())return;
if(s[pos]=='#'){
tree=NULL;
pos++;
}else{
tree=new node;
tree->data=s[pos++];
create(tree->lchild);
create(tree->rchild);
}
}
//void deletetree(node* &tree){
// void deletetree(node* &tree){
// if (tree != NULL){
// if (tree->lchild != NULL){
// deletetree(tree->lchild);
// tree->lchild = NULL;
// }
//
// if (tree->rchild != NULL){
// deletetree(tree->rchild);
// tree->rchild = NULL;
// }
// delete tree;//关...
登录后发布评论
暂无评论,来抢沙发