-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw6.cpp
59 lines (48 loc) · 1.01 KB
/
hw6.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
54
55
56
57
58
59
#include <iostream>
using namespace std;
int main()
{
int integer1 = 0;
int integer2 = 0;
int integer3 = 0;
int smallest = 0;
int mid = 0;
int largest = 0;
cout << "Please enter three integers separated by space ";
cin >> integer1 >> integer2 >> integer3;
if (integer1 <= integer2 && integer1 <= integer3) {
smallest = integer1;
if (integer2 <= integer3) {
mid = integer2;
largest = integer3;
}
else {
mid = integer3;
largest = integer2;
}
}
else if (integer2 <= integer1 && integer2 <= integer3) {
smallest = integer2;
if (integer1 <= integer3) {
mid = integer1;
largest = integer3;
}
else {
mid = integer3;
largest = integer1;
}
}
else {
smallest = integer3;
if (integer1 <= integer2) {
mid = integer1;
largest = integer2;
}
else {
mid = integer2;
largest = integer1;
}
}
cout << "The values entered are sorted as : " << smallest << ", " << mid << ", " << largest << '\n';
return 0;
}