Skip to content

Commit c0974d3

Browse files
authored
Create evenarray.cpp
1 parent 23c8357 commit c0974d3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Algorithm/evenarray.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <iostream>
2+
#include <vector>
3+
using namespace std;
4+
int t,s,e,i;
5+
vector<int>v;
6+
int main()
7+
{ cin>>t;
8+
while(t--)
9+
{
10+
int a=0;
11+
int b=0;
12+
cin>>s;
13+
for(i=0;i<s;i++)
14+
{
15+
cin>>e;
16+
17+
if((e%2)==0&(i%2)!=0)
18+
{a+=1;}
19+
if((e%2)!=0&(i%2)==0)
20+
{b+=1;}
21+
}
22+
if(a==b)
23+
{cout<<a<<"\n";}
24+
else
25+
{cout<<-1<<"\n";}
26+
}
27+
}

0 commit comments

Comments
 (0)