-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrange.java
More file actions
36 lines (32 loc) · 1007 Bytes
/
Copy patharrange.java
File metadata and controls
36 lines (32 loc) · 1007 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
32
33
34
35
36
public class arrange {
public static void printPairs(int arr[]){
int count = 0;
for(int i=0; i<arr.length; i++){
for(int j=i+1; j<=arr.length; j++){
System.out.print("(" + arr[i] + ","+ j+ ")");
count++;
}
System.out.println();
}
System.out.println("pairs count is: " + count);
}
public static void subArray(int arr[]){
int count = 0;
for(int i=0; i<arr.length; i++){
for(int j=0; j<arr.length; j++){
for(int k=i; k<=j; k++){
System.out.print(arr[k]);
count++;
}
System.out.println();
}
System.out.println();
}
System.out.println("subarray count is: " + count);
}
public static void main(String args[]){
int arr[] = {1,2,3,4,5,6};
// printPairs(arr);
subArray(arr);
}
}