团体程序设计天梯赛L1-022 奇偶分家
2017-03-22 17:48
225 查看
L1-022. 奇偶分家
时间限制400 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
陈越
给定N个正整数,请统计奇数和偶数各有多少个?
输入格式:
输入第一行给出一个正整N(<= 1000);第2行给出N个正整数,以空格分隔。
输出格式:
在一行中先后输出奇数的个数、偶数的个数。中间以1个空格分隔。
输入样例:
9 88 74 101 26 15 0 34 22 77
输出样例:
3 6
——————————————————————————————————————
对于输入的数直接处理,直接记录奇数或偶数的个数
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;
#define inf 0x3f3f3f3f
int main()
{
int n,s;
scanf("%d",&n);
int a=0,b=0;
for(int i=0;i<n;i++)
{
scanf("%d",&s);
if(s%2==0)
b++;
else
a++;
}
printf("%d %d\n",a,b);
return 0;
}
相关文章推荐
- 团体程序设计天梯赛-练习集L1-022. 奇偶分家
- 团体程序设计天梯赛-练习集L1-022. 奇偶分家
- L1-022. 奇偶分家-PAT团体程序设计天梯赛GPLT
- ACM天梯赛练习L1-022. 奇偶分家
- PAT - 天梯赛 L1-022 奇偶分家
- 2016年团体程序设计天梯赛-初赛 - 奇偶分家 - Java
- PAT 天梯赛 L1-022. 奇偶分家 【水】
- L1-009. N个数求和-PAT团体程序设计天梯赛
- 团体程序设计天梯赛-练习集L1-023. 输出GPLT
- 团体程序设计天梯赛-练习集L1-011. A-B
- 团体程序设计天梯赛 L1-007. 念数字
- L1-025. 正整数A+B-PAT团体程序设计天梯赛GPLT
- L1-022. 奇偶分家 java
- PAT-L1-022.奇偶分家
- 团体程序设计天梯赛-练习集 -- L2-022. 重排链表
- PAT-团体程序设计天梯赛-练习集-L1-002. 打印沙漏
- 团体程序设计天梯赛L1-046 整除光棍
- 团体程序设计天梯赛-练习集L1-024. 后天
- 团体程序设计天梯赛-练习集L1-012. 计算指数
- 团体程序设计天梯赛 L1-008. 求整数段和