当前位置:网站首页>L1-022 odd even split (10 points)

L1-022 odd even split (10 points)

2022-07-04 07:29:00 Inter personal liabilities^

L1-022 Parity separation (10 branch )

Given N A positive integer , Please count the number of odd and even Numbers ?

Input format :
The first line of input gives us a positive integer N(≤1000); The first 2 Line is given N Nonnegative integers , Space off .

Output format :
Output the number of odd Numbers successively in a line 、 Number of even Numbers . In the middle to 1 Space separation .

sample input :

9
88 74 101 26 15 0 34 22 77

sample output :

3 6

AC Code

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<sstream>

using namespace std;
typedef long long ll;
const int N=100010;

int main()
{
    
	int n;
	int a = 0, b = 0;
	cin >> n;
	while(n -- )
	{
    
		int x;
		cin >> x;
		if(x % 2 == 0) b ++ ;
		else a ++ ;
	}
	cout << a << ' ' << b << endl;
	return 0;
}



原网站

版权声明
本文为[Inter personal liabilities^]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141533229491.html