PAT(Basic Level)_1012_数字分类
来源:互联网 发布:固定循环编程注意? 编辑:程序博客网 时间:2024/06/03 18:04
#include<stdio.h>int main() { int N, num; int A1 = 0; int A2 = 0, A2_flag = 0, A2_odd = 1; int A3 = 0; int A4 = 0, A4_cnt = 0; int A5 = 0; scanf("%d", &N); while (N--) { scanf("%d", &num); switch (num % 5) { case 0: if (!(num & 1)) A1 += num; break; case 1: A2_flag = 1; if (A2_odd) A2 += num, A2_odd = 0; else A2 -= num, A2_odd = 1; break; case 2: A3++; break; case 3: A4 += num; A4_cnt++; break; case 4: if (num > A5) A5 = num; break; } } if (A1) printf("%d ", A1); else printf("N "); if (A2_flag) printf("%d ", A2); else printf("N "); if (A3) printf("%d ", A3); else printf("N "); if (A4) printf("%.1lf ", ((double)A4)/A4_cnt); else printf("N "); if (A5) printf("%d", A5); else printf("N"); return 0;}
阅读全文
0 0
- PAT(Basic Level)_1012_数字分类
- 【PAT 乙级(Basic Level)】数字分类
- PAT (Basic Level)1012. 数字分类
- PAT(Basic Level):数字分类(20)
- PAT BASIC LEVEL 1012. 数字分类 (20)
- PAT.Basic Level.T.1012.数字分类
- 【C++】浙大PAT (Basic Level)1012. 数字分类 (20)
- Pat(Basic Level)Practice--1012(数字分类)
- PAT Basic Level 1012. 数字分类(20)
- PAT (Basic Level) Practise (中文)1012. 数字分类 (20)
- PAT (Basic Level) Practise-1012. 数字分类 (20)
- PAT (Basic Level) Practise (中文)1012. 数字分类 (20)
- PAT (Basic Level) Practise (中文) 1012. 数字分类 (20)
- PAT (Basic Level) Practise (中文)1012. 数字分类 (20)
- PAT basic 1012 :数字分类
- PAT (Basic Level) Practise (中文)1012. 数字分类 (20) C语言
- 【PAT 乙级(Basic Level)】数字黑洞
- PAT (Basic Level)1019. 数字黑洞
- Codeforces 447B DZY Loves Strings
- Alignment of Code
- PAT(Basic Level)_1011_A+B和C
- xgb原理及使用
- Centos下修改mysql的默认编码方式
- PAT(Basic Level)_1012_数字分类
- Ducci Sequence
- java中的迭代器模式
- oracle常用
- [模板]manacher算法
- Digital Roots
- Ubuntu14.04下安装ros indigo opencv2.4.11
- JS学习(10)----DOM
- 南阳理工oj-水池数目