1 #include<stdio.h> 2 void swap(int *x, int *y) 3 { 4 int temp = 0; 5 temp = *x; 6 *x = *y; 7 *y = temp; 8 return; 9 } 10 11 int main(int argc, const char *argv[]) 12 { 13 int a = 0, b = 0;//定义需要传给形参,给形参赋值的变量 14 printf("plese input two number:"); 15 scanf("%d%d",&a,&b); 16 printf("a = %d,b = %d\n",a , b); 17 swap(&a, &b); 18 19 printf("a = %d,b = %d\n",a , b); 20 return 0; 21 }