将两个整数交换次序后输出
一、
1.设置一个值传递的函数
二、
三、
#include<iostream>
using namespace std;
void jiaohuan(int &a,int &b)
{
int team;
team=a;
a=b;
b=team;
}
int main()
{
int x,y;
cin>>x>>y;
jiaohuan(x,y);
cout<<""<<x<<" "<<y<<endl;
return 0;
}
四、
#include<iostream>
using namespace std;
void jiaohuan(int &a,int &b)
{
int team;
team=a;
a=b;
b=team;
}
int main()
{
int x,y;
cin>>x>>y;
jiaohuan(x,y);
cout<<""<<x<<" "<<y<<endl;
return 0;
}