输入两个数,交换两个数的数值
#include<stdio.h>
void Swap(int* px,int* py){
int z = *px;
*px = *py;
*py = z;
}
int main(){
int a = 0;
int b = 0;
scanf("%d %d",&a,&b);
printf("交换前:a = %d b = %d\n",a,b);
Swap(&a,&b);
printf("交换后:a = %d b = %d\n",a,b);
return 0;
}
编译结果: