code4sk/c/sourcecode/朱森森带领的奇妙冒险/数组2/角色交换.cpp
2023-10-18 16:17:32 +08:00

18 lines
252 B
C++

//½ÇÉ«½»»»
#include<stdio.h>
void swap(int *px,int *py);
int main()
{
int a=1,b=2;
int *pa=&a,*pb=&b;
swap(pa,pb);
printf("After calling swap:a=%d b=%d\n",a,b);
return 0;
}
void swap(int *px,int *py)
{
int t;
t=*px;
*px=*py;
*py=t;
}