-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFun11.java
More file actions
35 lines (29 loc) · 605 Bytes
/
Fun11.java
File metadata and controls
35 lines (29 loc) · 605 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
package funsimple;
public class Fun11 {
static int a, b;
public static void main(String[] args) {
a = 8;
b = 7;
show();
sort2();
show(); // 7, 8
}
// o'sish tartibida
public static void sort2() {
if (a > b) swap();
}
// ikki sonni o'rnini almashtirish
public static void swap() {
int t = a;
a = b;
b = t;
/*
a = a + b; // a = 15
b = a - b; // b = 7
a = a - b; // a = 8
*/
}
public static void show() {
System.out.printf("%d, %d\n", a, b);
}
}