//值传递 void swap(int i,int j){ printf("交换后: "); int tmp; tmp = i; i = j; j = tmp; } //引用传递,传递地址 void swap1(int* p,int* q){ printf("交换后: "); int tmp; tmp = *p; *p = *q; *q = tmp; } main(){ int i =3; int j = 5; printf("i=%d ",i); //i = 3 printf("j=%d ",j); //j = 5 //交换数值 swap1(&i,&j); printf("i=%d ",i); //i = 5 printf("j=%d ",j); //i = 3 }