| 1 | // File: fig0627.cpp |
| 2 | // Computer Systems, Fourth Edition |
| 3 | // Figure 6.27 |
| 4 | |
| 5 | #include <iostream> |
| 6 | using namespace std; |
| 7 | |
| 8 | int a, b; |
| 9 | |
| 10 | void swap (int& r, int& s) { |
| 11 | int temp; |
| 12 | temp = r; |
| 13 | r = s; |
| 14 | s = temp; |
| 15 | } |
| 16 | |
| 17 | void order (int& x, int& y) { |
| 18 | if (x > y) { |
| 19 | swap (x, y); |
| 20 | } // ra2 |
| 21 | } |
| 22 | |
| 23 | int main () { |
| 24 | cout << "Enter an integer: "; |
| 25 | cin >> a; |
| 26 | cout << "Enter an integer: "; |
| 27 | cin >> b; |
| 28 | order (a, b); |
| 29 | cout << "Ordered they are: " << a << ", " << b << endl; // ra1 |
| 30 | return 0; |
| 31 | } |