编译器说 [Linker error] undefined reference to `WinMain@16' ld returned 1 exit status 怎么修改
#include<iostream>usingnamespacestd;structDoubletree{chardata;structDoubletree*lefttr...
#include <iostream>
using namespace std;
struct Doubletree
{
char data;
struct Doubletree*lefttree;
struct Doubletree*righttree;
};
Doubletree*buildtree()
{
Doubletree*T;
char p;
cout<<"please input a number"<<endl;
cin>>p;
if(p=='a')
T=NULL;
else
{
T->data=p;
T->lefttree=buildtree();
T->righttree=buildtree();
}
return T;
}
void print(char p,int&count)
{
cout<<p<<endl;
count++;
};
void iter(Doubletree*T,int&count)
{
if(T)
{
print(T->data,count);
iter(T->lefttree, count);
iter(T->righttree, count);
}
};
int man()
{
int count=0;
Doubletree*T;
T=buildtree();
iter(T,count);
cout<<"the number is"<<count<<endl;
system("pause");
return 0;
} 展开
using namespace std;
struct Doubletree
{
char data;
struct Doubletree*lefttree;
struct Doubletree*righttree;
};
Doubletree*buildtree()
{
Doubletree*T;
char p;
cout<<"please input a number"<<endl;
cin>>p;
if(p=='a')
T=NULL;
else
{
T->data=p;
T->lefttree=buildtree();
T->righttree=buildtree();
}
return T;
}
void print(char p,int&count)
{
cout<<p<<endl;
count++;
};
void iter(Doubletree*T,int&count)
{
if(T)
{
print(T->data,count);
iter(T->lefttree, count);
iter(T->righttree, count);
}
};
int man()
{
int count=0;
Doubletree*T;
T=buildtree();
iter(T,count);
cout<<"the number is"<<count<<endl;
system("pause");
return 0;
} 展开
2个回答
展开全部
以编译器的意思是说你少定义了某个头文件, 但其实是打错了字
man()改成main()
对你的代码某个部分优化:
Doubletree*T=NULL;
char p;
cout<<"please input a number"<<endl;
cin>>p;
if(p=='a');
else
{
T->data=p;
T->lefttree=buildtree();
T->righttree=buildtree();
}
return T;
这只解决了链接问题,其实还有问题,估计用了指针中保存的变量地址了,程序运行一会儿就崩溃 。
man()改成main()
对你的代码某个部分优化:
Doubletree*T=NULL;
char p;
cout<<"please input a number"<<endl;
cin>>p;
if(p=='a');
else
{
T->data=p;
T->lefttree=buildtree();
T->righttree=buildtree();
}
return T;
这只解决了链接问题,其实还有问题,估计用了指针中保存的变量地址了,程序运行一会儿就崩溃 。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询