swap() 交換兩個數
#include <stdio.h> void swap(int *x, int *y)//傳入指針 { int tmp; tmp = *x; *x = *y; *y = tmp; } int main() { int a = 3; int b = 5; printf("a = %d, b = %d\n", a, b); swap(&a, &b); printf("a = %d, b = %d\n", a, b); return 0; }
最後更新:2017-04-03 16:48:53