-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmocktest.java
More file actions
45 lines (36 loc) · 783 Bytes
/
mocktest.java
File metadata and controls
45 lines (36 loc) · 783 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
import java.util.Scanner;
public class mocktest {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner ss=new Scanner(System.in);
int N=ss.nextInt();
int b =ss.nextInt();
int c=ss.nextInt();
int[] arr=new int[N];
for(int i=0;i<N;i++)
{
arr[i]=ss.nextInt();
}
// for(int i=0;i<N;i++)
// {
// System.out.println(arr[i]);
// }
book(arr,b,c);
}
public static void book(int[] array,int x,int y)
{
int d=0;
for(int i=0;i<array.length;i++)
{ int sum=0;
for(int j=i;j<array.length;j++) {
sum=sum+array[j];
if(sum>=x && sum<=y) {
d++;
//System.out.println(sum);
}
//if(sum>d)continue;
}
}
System.out.print(d);
}
}