Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- // prototypes for the other functions used
- void compare(int*, int*);
- void swap(int*, int*);
- // sends the inputs in pairs to sortItOut for simplier sorting
- void smallSort2(int* a, int* b, int* c)
- {
- compare(a, b);
- compare(a, c);
- compare(b, c);
- }
- // determines if the inputs need to be sorted, or if they are already in the
- // correct order
- void compare(int* a, int* b)
- {
- if (*a > *b)
- swap(a, b);
- }
- // if the values needed to be swapped then they will have their positions
- // "switched" in memory, that is why they are passed by reference
- void swap(int* first, int* second)
- {
- int temp = *first;
- *first = *second;
- *second = temp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement