代码实现:
#include<stdio.h>
int main()
{
int N, *a;
scanf("%d", &N);
a = (int*)malloc(sizeof(int)*N);
for (int i = 0; i < N; i++)scanf("%d", &a[i]);
int A[5] = { 0,0,0,0,0 }, flag = 1, cnt = 0, judge = 0;
for (int i = 0; i < N; i++)
{
if (a[i] % 5 == 0 && a[i] % 2 == 0)A[0] += a[i];
else if (a[i] % 5 == 1)
{
A[1] += a[i] * flag;
flag *= -1; judge = 1;
}
else if (a[i] % 5 == 2)A[2]++;
else if (a[i] % 5 == 3)
{
A[3] += a[i];
cnt++;
}
else if (a[i] % 5 == 4)
if (A[4] < a[i])A[4] = a[i];
}
for (int i = 0; i < 5; i++)
if (i == 0)
{
if (A[i] == 0)printf("N");
else printf("%d", A[i]);
}
else if (i == 1)
if (judge == 0)printf(" N");
else printf(" %d", A[1]);
else if (i == 3)
{
if (A[i] == 0)printf(" N");
else printf(" %.1f", 1.0*A[i] / cnt);
}
else
{
if (A[i] == 0)printf(" N");
else printf(" %d", A[i]);
}
return 0;
}