Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public double bubblesort() {
- int unsortedArray[]=new int[10];
- int temp, counter, index,length=unsortedArray.length;
- for(int i=0;i<length-1;i++){
- unsortedArray[i]=(int) (Math.random()*100);
- System.out.print(""+unsortedArray[i]+", ");
- }
- acc.setEnabled(false);
- proglbl.setText("Bubblesort benchmark");
- jpb.setValue(0);
- jpb.setMaximum(length-1);
- reslbl.setText("");
- for(counter=0; counter<length; counter++) {
- for(index=0; index<length-1-counter; index++) {
- if(unsortedArray[index] < unsortedArray[index+1]) {
- temp = unsortedArray[index];
- unsortedArray[index] = unsortedArray[index+1];
- unsortedArray[index+1] = temp;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement