-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubArrayFinding.java
More file actions
51 lines (49 loc) · 890 Bytes
/
SubArrayFinding.java
File metadata and controls
51 lines (49 loc) · 890 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package pra;
import java.util.*;
public class SubArrayFinding {
public static void main(String args[])
{
//input
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number:");
int n=sc.nextInt();
int arr[]=new int[n];
System.out.println("Enter the elements in array:");
for(int i=0;i<n;i++)
{
arr[i]=sc.nextInt();
}
sc.close();
//logic
/*
for(int k=0;k<n;k++)
{
int temp=k;
for(int i=k;i<n;i++)
{
for(int j=i;j<n;j++)
{
System.out.print(temp+" ");
temp++;
}
System.out.println();
temp=k;
}
}*/
//logic
for(int k=0;k<n;k++)
{
int temp=k;
for(int i=k;i<n;i++)
{
for(int j=i;j<n;j++)
{
System.out.print(arr[temp]+" ");
temp++;
}
System.out.println();
temp=k;
}
}
}
}