forked from IPC1s2017/TareaFinal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEF2.java
More file actions
36 lines (27 loc) · 915 Bytes
/
Copy pathEF2.java
File metadata and controls
36 lines (27 loc) · 915 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
public class EF2{
public static void main(String[] args) {
int array[] ={2, 3, 8, 109, 13, 4, 18, 10, 23, 18, 50, 11, 13, 2};
BubbleSort bs= new BubbleSort();
bs.sort(array);
bs.print(array);
}
public void sort(int array[]){
for(int i=0; i<=array.length; i++){
for(int j=1; j<array.length; j++){
if(array[j-1]>array[j]){
int temp = array[j];
array[j] = array[j-1];
array[j-1]=temp;
}
}
}
}
public void print(int array[]){
System.out.println("{");
for(int i : array){ //Esto se conoce como foreach
System.out.print(i+",");
System.out.println("");
}
System.out.println("}");
}
}