-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBubbleSort.java
51 lines (40 loc) · 1.36 KB
/
BubbleSort.java
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.*;
public class BubbleSort{
// public static void main(String[] args) {
// int arr[] = {2,5,7,3,8};
// Arrays.sort(arr);
// for(int i = 0;i<arr.length;i++){
// System.out.print(arr[i]+" ");
// }
// }
// public static void main(String[] args) {
// Scanner sc = new Scanner(System.in);
// System.out.print("Enter the length of the array: ");
// int length = sc.nextInt();
// int arr[] = new int[length];
// for(int i = 0;i<length;i++){
// arr[i] = sc.nextInt();
// };
// for(int i = 0;i<arr.length;i++){
// System.out.print(arr[i]+" ");
// }
// }
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter first array numbers: ");
int first = sc.nextInt();
System.out.println("Enter second array numbers: ");
int second = sc.nextInt();
int arr[][] = new int[first][second];
for(int i = 0;i<first;++i){
for(int j = 0;j<second;++j){
arr[i][j] = sc.nextInt();
}
}
for(int i = 0;i<first;++i){
for(int j = 0;j<second;++j){
System.out.print(arr[i][j]+" ");
}
}
}
}