#include <iostream.h>
void swap(int&,int&,int&);
void main()
{
int a=99, b=5,c=39;
cout<<"a="<<a<<",b="<<b<<",c="<<c<<endl;
swap(a,b,c);
cout<<"swapped:"<<endl;
cout<<"a="<<a<<",b="<<b<<",c="<<c<<endl;
}
void swap(int&x,int&y,int&m)
{
int temp;
temp=x;
x=y;
y=m;
m=temp;
}
引用传递方式交换3个变量的值
最新推荐文章于 2022-12-26 13:38:01 发布