#include <stdio.h> void swap(int *p1,int *p2) { int tmp=*p1; *p1=*p2; *p2=tmp; }
void swap1(int *p1,int *p2)
{
*p1=*p1+*p2;
*p2=*p1-*p2;
*p1=*p1-*p2;
}
main() { int a=1,b=2; swap(&a,&b); printf("%d %d",a,b); getchar(); }
结果: 2 1
标签:p2,tmp,p1,变量,int,void,C语言,指针 From: https://www.cnblogs.com/xkdn/p/16705622.html