模拟 : 1012 数字分类 (20 分)

1012 数字分类 (20 分)

#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
	int n;
	if(scanf("%d",&n)!=EOF){
		int a[6]={},b[6]={};
		for(int i=0;i<n;i++){
			int num;
			if(scanf("%d",&num)!=EOF){
				if(0==num%5&&0==num%2)a[1]+=num,b[1]++;
				if(1==num%5){
					if((b[2]+1)&1)a[2]+=num;
					else a[2]-=num;
					b[2]++;
				}
				if(2==num%5)b[3]++;
				if(3==num%5)a[4]+=num,b[4]++;
				if(4==num%5&&num>a[5])a[5]=num,b[5]++;
			}
		}
		if(0==b[1])printf("N ");
		else 	 printf("%d ",a[1]);
		if(0==b[2])printf("N ");
		else 	 printf("%d ",a[2]);
		if(0==b[3])printf("N ");
		else 	 printf("%d ",b[3]);
		if(0==b[4])printf("N ");
		else 	 printf("%.1lf ",(double)a[4]/b[4]);
		if(0==b[5])printf("N\n");
		else 	 printf("%d\n",a[5]);
	}
	return 0;
}

 

上一篇:PAT乙级-1012 数字分类 (20 分)


下一篇:1012 数字分类 (20 分)