-
Notifications
You must be signed in to change notification settings - Fork 0
/
mjehuric.cpp
66 lines (50 loc) · 870 Bytes
/
mjehuric.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
60
61
62
63
64
65
#include <iostream>
using namespace std;
typedef short int sint;
sint arr[5];
sint temp;
bool gr;
void printAll() {
for(sint i=0; i<5; ++i) {
cout << arr[i] << " ";
}
cout << endl;
}
int main() {
for(sint i=0; i<5; ++i) {
cin >> arr[i];
}
while(true) {
gr = false;
if(arr[0] > arr[1]) {
temp = arr[0];
arr[0] = arr[1];
arr[1] = temp;
gr = true;
printAll();
}
if(arr[1] > arr[2]) {
temp = arr[1];
arr[1] = arr[2];
arr[2] = temp;
gr = true;
printAll();
}
if(arr[2] > arr[3]) {
temp = arr[2];
arr[2] = arr[3];
arr[3] = temp;
gr = true;
printAll();
}
if(arr[3] > arr[4]) {
temp = arr[3];
arr[3] = arr[4];
arr[4] = temp;
gr = true;
printAll();
}
if(!gr) break;
}
return 0;
}