y x
play

y = x; } int a = 2, b = 6; swap(a,b); void swap(int x, int y) { - PowerPoint PPT Presentation

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; }


  1. void swap(int x, int y) { x = y; y = x; } … int a = 2, b = 6; swap(a,b);

  2. void swap(int x, int y) { int temp = y; y = x; x = temp; } … int a = 2, b = 6; swap(a,b);

  3. void swap(int* x, int* y) { int* temp = y; y = x; x = temp; } … int a = 2, b = 6; swap(a,b);

  4. void swap(int* x, int* y) { int temp = *y; *y = *x; *x = temp; } … int a = 2, b = 6; swap(a,b);

  5. • • • –

Recommend


More recommend