#include<iostream>
#include<cstdio>
using namespace std;
//(1)传值
void myswap1(int x, int y)
{
int t;
t=x;
x=y;
y=t;
}
//(2)传地址
void myswap2(int *p1, int *p2)
{
int t;
t=*p1;
*p1=*p2;
*p2=t;
}
//(3)引用作形参
void myswap3(int &x, int &y)
{
int t;
t=x;
x=y;
y=t;
}
int main()
{
int a, b,c;
int *p1,*p2;
p1=&a;
p2=&b;
printf("请输入待交换的两个整数:");
scanf("%d %d", &a, &b);
myswap1(a,b);
printf("调用交换函数后的结果是:%d 和 %d\n", a, b);
myswap2(p1,p2);
printf("调用交换函数后的结果是:%d 和 %d\n", a, b);
myswap3(a,b);
c=a;a=b;b=c;
printf("调用交换函数后的结果是:%d 和 %d\n", a, b);
return 0;
}