-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArraysHH.java
More file actions
26 lines (24 loc) · 777 Bytes
/
Copy pathArraysHH.java
File metadata and controls
26 lines (24 loc) · 777 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
import java.util.*;
public class ArraysHH {
// print sub-arrays
public static void printSubarrays(int numbers[]) {
int ts=0;
for (int i=0; i<numbers.length; i++){
int start=i;
for (int j =i; j<numbers.length;j++){
int end=j;
for (int k=start; k<=end; k++){//print
System.out.print(numbers[k]+" ");//subarray
}
ts++;
System.out.println();
}
System.out.println();
}
System.out.println("Total no of sub-arrays : "+ ts);
}
public static void main(String args[]) {
int numbers[]={2,4,6,8,10};
printSubarrays(numbers);
}
}