主题:一道c++程序的小问题
[size=4]编写一道程序如下,
//guess:yanghuisanjiao
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int i,j;
for(i=1;i<=9;i++)
{
for(j=1;j<=(9-i);j++)
cout<<" ";
for(j=1;j<=i;j++)
cout<<setw(1)<<j;
for(j=(i-1);j>=1;j--)
cout<<setw(1)<<j;
cout<<endl;
}
return 0;
}
可是在运行的时候出现了错误
--------------------Configuration: yanghui - Win32 Debug--------------------
Compiling...
yanghui.cpp
Linking...
yanghui.obj : error LNK2005: _main already defined in y2.obj
Debug/yanghui.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
yanghui.exe - 1 error(s), 0 warning(s)
请问这是怎么回事,该怎么修改[/size]
//guess:yanghuisanjiao
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int i,j;
for(i=1;i<=9;i++)
{
for(j=1;j<=(9-i);j++)
cout<<" ";
for(j=1;j<=i;j++)
cout<<setw(1)<<j;
for(j=(i-1);j>=1;j--)
cout<<setw(1)<<j;
cout<<endl;
}
return 0;
}
可是在运行的时候出现了错误
--------------------Configuration: yanghui - Win32 Debug--------------------
Compiling...
yanghui.cpp
Linking...
yanghui.obj : error LNK2005: _main already defined in y2.obj
Debug/yanghui.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
yanghui.exe - 1 error(s), 0 warning(s)
请问这是怎么回事,该怎么修改[/size]