![]() |
#2
玩出来的代码2010-03-18 14:16
|

#include<iostream>
using namespace std;
int main()
{
void swap(int x,int y,int z);
int x,y,z;
cout<<"Please enter three number:";
cin>>x>>y>>z;
swap(x,y,z);
return 0;
}
void swap (int &a,int &b,int &c)
{
int d;
if (a>b){d=a;a=b;b=d;}
if(c>b)cout<<a<<" "<<b<<" "<<c<<endl;
else if(c<a)cout<<a<<" "<<a<<" "<<b<<endl;
else cout<<a<<" "<<c<<" "<<b<<endl;
}
运行结果using namespace std;
int main()
{
void swap(int x,int y,int z);
int x,y,z;
cout<<"Please enter three number:";
cin>>x>>y>>z;
swap(x,y,z);
return 0;
}
void swap (int &a,int &b,int &c)
{
int d;
if (a>b){d=a;a=b;b=d;}
if(c>b)cout<<a<<" "<<b<<" "<<c<<endl;
else if(c<a)cout<<a<<" "<<a<<" "<<b<<endl;
else cout<<a<<" "<<c<<" "<<b<<endl;
}
Configuration: 1 - Win32 Debug--------------------
Linking...
11.obj : error LNK2001: unresolved external symbol "void __cdecl swap(int,int,int)" (?swap@@YAXHHH@Z)
Debug/1.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
1.exe - 1 error(s), 0 warning(s)