题目:
![](https://i-blog.csdnimg.cn/blog_migrate/026272aa16be6dcb2c976f7a42b62257.png)
解答:
#include "stdio.h"
int main(){
int A1=0,A2=0,A3=0,A4=0,A5=0;
//cnt是余数为3的个数,flag_A2记录A2出现,sign控制符号
int cnt=0,flag_A2=0,sign=1;
int N,num;
scanf("%d ",&N);
while(N--){
scanf("%d ",&num);
//根据余数进行判断
switch (num%5){
case 0:
A1+=num%2==0?num:0; break;
case 1:
A2+=sign*num;sign*=-1;flag_A2=1;break;
case 2:
A3++;break;
case 3:
A4+=num;cnt++;break;
default:
A5=num>A5?num:A5;break;
}
}
//输出判断
if(A1){
printf("%d ",A1);
}else{
printf("N ");
}
if(flag_A2){
printf("%d ",A2);
}else{
printf("N ");
}
if(A3){
printf("%d ",A3);
}else{
printf("N ");
}
if(A4){
printf("%.1f ",(float)A4/cnt);
}else{
printf("N ");
}
if(A5){
printf("%d",A5);
}else{
printf("N");
}
}