-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathArrayadd.java
62 lines (58 loc) · 877 Bytes
/
Arrayadd.java
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
52
53
54
55
56
57
58
59
60
61
62
import java.util.*;
public class Arrayadd
{
public static void main(String args[])
{
/*
int sum1=0;
int res=0;
int arr[]={1,2,3,4};
for(int i=0;i<arr[3];i++)
{
if(arr[i]%2==0)
{
sum1=sum1+arr[i];
}
else
{
res+=arr[i];
//System.out.println(res);
}
}
System.out.println(sum1);
System.out.println(res);
*/
int n;
Scanner sc=new Scanner(System.in);
int sum=0;
int res=0;
n=sc.nextInt();
int arr[]=new int[n];
for(int i=0;i<n;i++)
{
arr[i]=sc.nextInt();
}
for(int i=0;i<n;i++)
{
if(arr[i]%2==0)
{
sum=sum+arr[i];
}
else
{
res=res+arr[i];
}
}
System.out.println(sum);
System.out.println(res);
/*
int[] x=new int[10];
Scanner sc=new Scanner(System.in);
for(int i=0;i<=9;i++)
{
x[i]=sc.nextInt();
}
for(int i=0;i<=9;i++)
System.out.println(x[i]);*/
}
}