(注
數據結構練習題
(注
#include
#include
#include
void exit(int);
#define MAX
typedef struct node{
char d;
struct node *lchild
}Tnode;
void MKTree(char in[]
{
int i;
if(is< p>
*r=NULL;
else{
*r=malloc(sizeof(Tnode));
(*r)
for(i=is;i<=ie;i++)
if(post[poste]==in[i])
{
MKTree(in
MKTree(in
break;
}
if(i>ie){
printf(
exit(
}
}
}
void BST(char in[]
{
int i;
if(is==ie)
printf(
else
{
for(i=is;i<=ie;i++)
{
if(in[i]< p>
continue;
else
break;
}
if(i==ie)
printf(
else
printf(
}
}
void preorder(Tnode *r)
{
if(r)
{
printf(
preorder(r
preorder(r
}
}
int seconde(Tnode *r)
{
if(r==NULL)
return
else
if((r
return
else
return seconde(r
}
void main()
{
Tnode *r;
char post[MAX]
printf(
gets(in);
gets(post);
MKTree(in
printf(
preorder(r);
printf(
printf(
BST(in
}
(注
#include
#define max
main()
{
int a[max];
int n=
printf(
do{
scanf(
if(d==
break;
n++;
a[n]=d;
}while(
for(i=n;i>
printf(
printf(
}
[
From:http://tw.wingwit.com/Article/program/sjjg/201311/23798.html