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
48 lines (38 loc) · 1.05 KB
/
Copy pathEF2.java
File metadata and controls
48 lines (38 loc) · 1.05 KB
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
package ef2;
/**
*
* @author lenovo
*/
public class EF2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int array[]= {2,3,8,109,13,4,18,10,23,18,50,11,13,2};
EF2 ps= new EF2();
ps.sort(array);
ps.print(array);
}
public void sort(int array[]){
for (int i=0; i<array.length; i++){
for (int j=1; j<array.length -i; j++){
if (array[j-1]>array[j]){
int temporal=array[j];
array[j]=array[j-1];
array[j-1]=temporal;
}
}
}
}
public void print(int array[]){
//esto es un for each
System.out.print("{");
for (int i=0;i<array.length;i++){
System.out.print(array[i]);
if(i<array.length-1){
System.out.print(",");
}
}
System.out.println("}");
}
}