-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC2.cpp
More file actions
38 lines (34 loc) · 990 Bytes
/
C2.cpp
File metadata and controls
38 lines (34 loc) · 990 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
/*Given N numbers. Count how many of these values are even, odd, positive and negative.
Input
First line contains one number N (1 ≤ N ≤ 103) number of values.
Second line contains N numbers (-105 ≤ Xi ≤ 105).
Output
Print four lines with the following format:
First Line: "Even: X", where X is the number of even numbers in the given input.
Second Line: "Odd: X", where X is the number of odd numbers in the given input.
Third Line: "Positive: X", where X is the number of positive numbers in the given input.
Fourth Line: "Negative: X", where X is the number of negative numbers in the given input.*/
#include <iostream>
using namespace std;
int main() {
long long N,X,E,O,P,NV;
cin >> N;
E=0;
O=0;
P=O;
NV=0;
for (int i =0;i<N;i++){
cin>>X;
if (X%2==0)
{
E++;
}else{O++;}
if (X>0)
{
P++;
}if (X<0)
{NV++;}
}
cout<<"Even: "<<E<<endl<<"Odd: "<<O<<endl<<"Positive: "<<P<<endl<<"Negative: "<<NV;
return 0;
}