Charming Three
Bob thinks three is a lucky number - the Three Musketeers, the Holy Trinity, the three witches in Macbeth - it pops up everywhere. So he always collects numbers in groups of three.
However, what's better than three numbers? Three sorted numbers! Let's help Bob out.
Write a function, sort_three, that takes in three integer pointers as arguments and sorts the values they point to in increasing order.
If you would like a challenge, try to accomplish this by using a single comparison operator, > no more than three times!
Input Format
The function prototype of sort_three
is
void sort_three(int *x, int *y, int *z);
where x
, y
and z
are the three integer pointers.
Constraints
All numbers that the pointer points to are positive.
Output Format
The function sort_three
does not print anything. It changes what x
, y
and z
point to in place.
Examples
Example 0
Input: 5 2 7
Output: 2 5 7
Explanation: Sorts the numbers in ascending order.