int temp = A[i]; A[i] = A[j]; A[j] = temp;
x = StackPop(S); y = StackPop(S); StackPush(S, x); StackPush(S, y);
... swap the two elements at the front of queue Q ...