|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
#include<stdlib.h>
typedef char ElemType;
typedef enum {Link,Thread}PointerTag;
typedef struct BiThrNode
{
char data;
struct BiThrNode *lchild,*rchild;
PointerTag ltag,rtag;
} BiThrNode, *BiThrTree;
BiThrTree pre;
void chuangjian(BiThrTree *T)
{
char c;
scanf("%c",&c);
if(c==' ')
{
*T=NULL;
}
else
{
*T=(BiThrNode*)malloc(sizeof(BiThrNode));
(*T)->data=c;
(*T)->ltag=Link;
(*T)->rtag=Link;
chuangjian(&(*T)->lchild);
chuangjian(&(*T)->rchild);
}
}
void xiansuohua(BiThrTree T)
{
if(T)
{
xiansuohua(T->lchild);
if(!T->lchild)
{
T->ltag=Thread;
T->lchild=pre;
}
if(!pre->rchild)
{
pre->rtag=Thread;
pre->rchild=T;
}
pre=T;
xiansuohua(T->rchild);
}
}
void toujiedian(BiThrTree *p,BiThrTree T)
{
*p=(BiThrTree)malloc(sizeof(BiThrNode));
(*p)->ltag=Link;
(*p)->rtag=Thread;
(*p)->rchild=*p;
if(!T)
{
(*p)->lchild=*p;
}
else
{
(*p)->lchild=T;
pre=*p;
xiansuohua(T);
pre->rchild=*p;
pre->rtag=Thread;
(*p)->rchild=pre;
}
}
void visit(char c)
{
printf("%c",c);
}
void bianli(BiThrTree T)
{
BiThrTree p;
p=T->lchild;
while(p!=T)
{
while(p->ltag)
{
p=p->lchild;
}
visit(p->data);
while(p->rtag==Thread&&p->rchild!=T)
{
p=p->rchild;
visit(p->data);
}
p=p->rchild;
}
}
int mian()
{
BiThrTree P,T=NULL;
chuangjian(&T);
toujiedian(&P,T);
printf("中序遍历的结果为:");
bianli(P);
return 0;
}
错误:LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/001.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
001.exe - 1 error(s), 0 warning(s)
小甲鱼的这个代码我打出来为什么是错的?那位大神指点我一下。。万分感谢!!!
|
|
|
|
|