forked from Chrinkus/stroustrup-ppp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex06_sort_ints.cpp
53 lines (42 loc) · 1021 Bytes
/
ex06_sort_ints.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "../text_lib/std_lib_facilities.h"
int main()
{
// Program
cout << "Please enter 3 integer values to sort:\n";
int val1;
int val2;
int val3;
int greatest = 0;
int middlest = 0;
int smallest = 0;
cin >> val1 >> val2 >> val3;
if (val1 < val2 && val1 < val3) {
smallest = val1;
if (val2 < val3) {
middlest = val2;
greatest = val3;
} else {
middlest = val3;
greatest = val2;
}
} else if (val2 < val3){
smallest = val2;
if (val1 < val3) {
middlest = val1;
greatest = val3;
} else {
middlest = val3;
greatest = val1;
}
} else {
smallest = val3;
if (val1 < val2) {
middlest = val1;
greatest = val2;
} else {
middlest = val2;
greatest = val3;
}
}
cout << smallest << " " << middlest << " " << greatest << '\n';
}