题目链接在此。
#include<stdio.h>
int main(){
int n;
int temp;
double a1=0,a2=0,a3=0,a4=0,a5=0;
int zero[10000],one[10000],two[10000],three[10000],four[10000];
int z=0,o=0,tw=0,th=0,f=0;
scanf("%d",&n);
for(int i = 0 ; i < n; i++){
scanf("%d",&temp);
if(temp % 5 == 0){
zero[z++] = temp;
}else if(temp % 5 == 1){
one[o++] = temp;
}else if(temp % 5 == 2){
two[tw++] = temp;
}else if(temp % 5 == 3){
three[th++] = temp;
}else if(temp % 5 == 4){
four[f++] = temp;
}
}
//求A1
int A1 = 0;
for(int i = 0 ; i < z; i++){
if(zero[i]%2 == 0){
A1 += zero[i];
}
}
if(A1 == 0){
printf("N ");
}else{
printf("%d ",A1);
}
//求A2
if(o == 0){
printf("N ");
} else{
for(int i = 0 ; i < o; i++){
if(i % 2){
one[i] *= (-1);
}
a2 += one[i];
}
printf("%d ",(int)a2);
}
//求A3
if(tw == 0){
printf("N ");
} else{
printf("%d ",tw);
}
//求A4
if(th == 0){
printf("N ");
} else{
for(int i = 0; i < th; i++){
a4 += three[i];
}
printf("%.1f ",a4/th);
}
//求A5
if(f == 0){
printf("N\n");
} else{
int max = -1;
for(int i = 0 ; i < f; i++){
if(four[i] > max){
max = four[i];
}
}
printf("%d\n",max);
}
return 0;
}