It can't print "x|x" because you are using if statements on the same variable to determine the string. The value of the character on either side of the pipe is dependent on a single variable meaning only 1 can be 'x'. I can't tell what this is really supposed to do so I can't offer much more information.
There are 3 outcomes of this program:
Enter '1': prints "x|2"
Enter '2': prints "1|x"
Enter anything else: prints "1|2"
EDIT: Ah I see what you were trying to do. You wanted to run it twice and set the q and w separately. You can't do this because you're passing in the variables that are declared in the scope above it. Those functions have no access to those variables and cannot change those variables, they simply have access to references to those variables by passing them as parameters.