Skip to content

Commit 441726a

Browse files
Update Bubble.java
1 parent 30cc708 commit 441726a

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

Sorting/Bubble.java

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
1+
// Github: github.com/RodneyShag
2+
3+
import java.util.Scanner;
4+
15
public class Bubble {
6+
public static void main(String[] args) {
7+
/* Read input */
28

3-
public static void main(String[] args) {
4-
5-
6-
int a[]= {9,8,7,6,5,4,3,2,1};
9+
Scanner sc=new Scanner(System.in);
10+
System.out.print("Enter Number of Elements: ");
11+
int n=sc.nextInt();
12+
int a[]=new int[n];
13+
for(int i=0;i<n;i++)
14+
{
15+
a[i]=sc.nextInt();
16+
}
17+
System.out.println(" ");
18+
System.out.println("Elements");
19+
System.out.println(" ");
20+
for(int i=0;i<a.length;i++)
21+
{
22+
System.out.print(a[i]+" \t ");
23+
}
724

825
for(int i=0;i<a.length;i++)
926
{
@@ -19,15 +36,17 @@ public static void main(String[] args) {
1936

2037

2138
}
22-
39+
System.out.println(" \n");
40+
System.out.println(" ");
41+
System.out.println("Sorting Elements");
42+
System.out.println(" ");
2343
for(int i=0;i<a.length;i++)
2444
{
25-
System.out.println(a[i]+" \t");
45+
System.out.print(a[i]+" \t");
2646
}
2747

2848
}
2949

3050

3151
}
3252

33-

0 commit comments

Comments
 (0)