两数交换(指针)
#include <stdio.h>
void Swap(int *x,int *y);
int main()
{
int a,b;
printf("Enter a,b:");
scanf("%d,%d",&a,&b);
printf("Before swap:a=%d b=%d\n",a,b);
Swap(&a,&b);
printf("After swap:a=%d b=%d\n",a,b);
return 0;
}
void Swap(int *x,int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/ea1897689c45d6ad19e93762cf137ea9.png)