void swap(int x, int y) { x = y; y = x; } … int a = 2, b = 6; swap(a,b);
void swap(int x, int y) { int temp = y; y = x; x = temp; } … int a = 2, b = 6; swap(a,b);
void swap(int* x, int* y) { int* temp = y; y = x; x = temp; } … int a = 2, b = 6; swap(a,b);
void swap(int* x, int* y) { int temp = *y; *y = *x; *x = temp; } … int a = 2, b = 6; swap(a,b);
• • • –
Recommend
More recommend