printf("Before swap: x = %d,y = %d\n",x,y); swap(x,y); printf("After swap: x = %d,y = %d\n",x,y); printf("-------------------------------\n"); printf("Before swap_with_pt: x = %d,y = %d\n",x,y); swap_with_pt(&x,&y); printf("After swap_with_pt: x = %d,y = %d\n",x,y);
return0; }
输出
1 2 3 4 5 6 7
Before swap: x = 5,y = 10 In swap: x = 10,y = 5 After swap: x = 5,y = 10 --------------------------------- Before swap_with_pt: x = 5,y = 10 In swap_with_pt: x =10,y = 5 After swap_with_pt: x = 10,y = 5