Skip to content

Commit c359f04

Browse files
6 n 7 in succeeding order, then ignore the no between 6 and 7
1 parent 7261ef9 commit c359f04

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

arraySum.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import java.util.Scanner;
2+
class arraySum
3+
{
4+
public static void main(String args[])
5+
{
6+
int i,a=0,b=0,sum=0;
7+
Scanner sc = new Scanner(System.in);
8+
int n = sc.nextInt();
9+
int[] arr = new int[n];
10+
for(i=0;i<n;i++)
11+
{
12+
arr[i] = sc.nextInt();
13+
}
14+
for(i=0;i<n;i++)
15+
{
16+
if(arr[i]==6)
17+
a=i;
18+
if(arr[i]==7)
19+
b=i;
20+
}
21+
if(a<b)
22+
{
23+
for(i=0;i<n;i++)
24+
{
25+
if(i>=a && i<=b)
26+
continue;
27+
else
28+
sum+=arr[i];
29+
}
30+
}
31+
else
32+
{
33+
for(i=0;i<n;i++)
34+
{
35+
sum+=arr[i];
36+
}
37+
}
38+
System.out.println(sum);
39+
}
40+
}

0 commit comments

Comments
 (0)