-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFun12.java
More file actions
49 lines (40 loc) · 961 Bytes
/
Fun12.java
File metadata and controls
49 lines (40 loc) · 961 Bytes
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
package funsimple;
public class Fun12 {
static int a, b, c;
public static void main(String[] args) {
a = 3;
b = 2;
c = 3;
show(); // 3 2 3
sort3();
show(); // 2 3 3
}
// 2 9 7 -> 2 7 9
// 9 1 6 -> 1 6 9
// 6 1 9 -> 1 6 9
// 9 6 1 -> 1 6 9
public static void sort3() {
// avval dastlabki 2 tasi saralansin
if (a > b) {
int t = a;
a = b;
b = t;
} // a=6, b=9, c=1
// keyingi 2tasi saralansin
if (b > c) {
int t = b;
b = c;
c = t;
} // a=6, b=1, c=9
// avval dastlabki 2 tasi saralansin
if (a > b) {
int t = a;
a = b;
b = t;
} // a=1, b=6, c=9
}
public static void show() {
// System.out.printf("%d, %d, %d\n", a, b, c);
System.out.println(a + " " + b + " " + c);
}
}