Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author urksiful
- */
- import java.util.ArrayList;
- public class BubleSort {
- public static void main(String[] args) {
- ArrayList<Integer> arreglo = new ArrayList<Integer>();
- for(int i=0; i<100; i++){
- arreglo.add((int)(Math.random()*200)+1);
- System.out.print(arreglo.get(i)+" ");
- }
- int aux;
- for(int i=0; i<100-2; i++){
- for(int j=0; j<100-1; j++){
- if(arreglo.get(j+1)<arreglo.get(j)){
- aux = arreglo.get(j);
- arreglo.set(j, arreglo.get(j+1));
- arreglo.set(j+1, aux);
- }
- }
- }
- System.out.println("");
- for(int i=0; i<100; i++){
- System.out.print(arreglo.get(i)+" ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement