Last active
September 22, 2016 15:33
-
-
Save perforb/2dda9ce7a8388a4e8a469eea7525864b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package algorithm; | |
import java.util.Arrays; | |
public class BubbleSort | |
{ | |
public static void main(String[] args) | |
{ | |
int[] ints = {23220, 82319, 22, 9023090, 239, 11634}; | |
boolean flag = false; | |
do { | |
flag = false; | |
for (int i = 0, j = 0; i < ints.length -1 - j; i++) { | |
if (ints[i] > ints[i + 1]) { | |
int tmp = ints[i]; | |
ints[i] = ints[i + 1]; | |
ints[i + 1] = tmp; | |
flag = true; | |
j++; | |
} | |
} | |
} | |
while (flag); | |
Arrays.stream(ints).forEach(System.out::println); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 | |
239 | |
11634 | |
23220 | |
82319 | |
9023090 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment