-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBUBBLESORT.java
More file actions
31 lines (26 loc) · 887 Bytes
/
BUBBLESORT.java
File metadata and controls
31 lines (26 loc) · 887 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
import java.util.*;
public class BUBBLESORT {
public static void Bubble_Sort(int numbers[]) {
for (int i = 0; i < numbers.length - 1; i++) {
for (int j = 0; j < numbers.length - 1 - i; j++) {
if (numbers[j] > numbers[j + 1]) {
int temp = 0;
temp = numbers[j];
numbers[j] = numbers[j + 1];
numbers[j + 1] = temp;
System.out.print(numbers[i]);
}
}
}
}
public static void Printarray(int numbers[]) {
for (int i = 0; i < numbers.length; i++) {
System.out.print(numbers[i] + " ");
}
System.out.println();
}
public static void main(String args[]) {
int numbers[] = { 2, 4, 6, 8, 10 };
Bubble_Sort(numbers);
}
}