... swap(&p, &q); ...
Q: How must swap be changed?
void swap(int* a, int* b) { int temp = *a; *a = *b; *b = temp; }