弄了个C++程序能编译,链接时出错,请问错在哪儿?

来源:百度知道 编辑:UC知道 时间:2024/07/02 19:40:38
#include<iostream.h>
float count=0;
void main()
{

void h(int n,char c1,char c2,char c3);
int m;

cout<<"input the number of diskes:";
cin>>m;
h(m,'a','b','c');
cout<<m<<"disk's step is "<<count;
}
void h(int n,char c1,char c2,char c3)
{
if(n==1)
count++;
else
{
h(n-1,c1,c3,c2);
count++;
h(n-1,c2,c1,c3);
}
}
就是汉诺塔问题
链接后提示:
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/2.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

...没问题啊,是你的编译器有问题吧,具体是什么链接错误请写清楚.

能运行啊 是不是汉诺塔啊

你把这个放主函数前看看,我弟这没有C++没办法给你运行。
void h(int n,char c1,char c2,char c3)
{
if(n==1)
count++;
else
{
h(n-1,c1,c3,c2);
count++;
h(n-1,c2,c1,c3);
}
}

我这里运行没问题,你的编译器出问题了吧,