64,663
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
void mymax(int &x, int &y); //先声明再使用,另外最好将函数的名字改改,因为标准库里也有个max函数
//和它同名易产生错误
int main(void)
{
int a = 1, b = 2;
mymax(a, b);
cout << "a=" << a << " b=" << b << endl;
return 0;
}
void mymax(int &x, int &y)
{
int temp;
temp = x;
x = y;
y = temp;
}
#include <iostream>
using namespace std;
#include <iostream>
using namespace std;
void max(int &x,int &y);
int main()
{
int a=1,b=2;
max(a,b);
cout <<"a=" <<a <<" b=" <<b <<endl;
}
void max(int &x,int &y)
{
int temp;
temp=x;
x=y;
y=temp;
}
cout << "a=" << a << " b=" << b << endl;
#include <iostream>
using namespace std;
#include <iostream.h>