-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNesneTabanlıProgramlamaSortOrnek.java
51 lines (47 loc) · 1.53 KB
/
NesneTabanlıProgramlamaSortOrnek.java
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
package javaapplication2;
public class JavaApplication2 {
// 3 sayiyi karsilastir ve sirala
static void Karsilastir(int s1, int s2, int s3){
if(s1 > s2 && s1 > s3){
if(s2 > s3){
System.out.println(s1 + " > " + s2 + " > " + s3 );
}else if(s3 > s2){
System.out.println(s1 + " > " + s3 + " > " + s2 );
}
}else if(s2 > s1 && s2 > s3){
if(s1 > s3){
System.out.println(s2 + " > " + s1 + " > " + s3 );
}else if(s3 > s1){
System.out.println(s2 + " > " + s3 + " > " + s1 );
}
}else{
if(s2 > s1){
System.out.println(s3 + " > " + s2 + " > " + s1 );
}else if(s1 > s2){
System.out.println(s3 + " > " + s1 + " > " + s2 );
}
}
}
// Dizinin eleman sayisi kadar döngü kurdurup karsilastirip siralat
static void Karsilastirma(int[] num){
int len = num.length;
int tmp;
for(int i=0; i < len-1; i++){
for (int j=0; j < len-1; j++){
if(num[j+1] > num[j]){
tmp = num[j+1];
num[j+1] = num[j];
num[j] = tmp;
}
}
}
for (int l=0; l < num.length; l++){
System.out.println(num[l]);
}
}
public static void main(String[] args) {
Karsilastir(10,20,30);
int[] num = {10,20,30,40,50,60,70,80,90,100};
Karsilastirma(num);
}
}