# 1012.数字分类(20) PAT

A1 = 能被5整除的数字中所有偶数的和；
A2 = 将被5除后余1的数字按给出顺序进行交错求和，即计算n1-n2+n3-n4…；
A3 = 被5除后余2的数字的个数；
A4 = 被5除后余3的数字的平均数，精确到小数点后1位；
A5 = 被5除后余4的数字中最大数字。

13 1 2 3 4 5 6 7 8 9 10 20 16 18

30 11 2 9.7 9

8 1 2 4 5 6 7 9 16

N 11 2 N 9

#include <stdio.h>
#include <stdlib.h>

int nagtive(int time){
int num = 1;
for(int i = 0; i < time;  i ++){
num *= -1;
}
return num;
}

int A1;
int a1;
int A2;
int A3;
float A4;
int A5;

int main(){
int num;
int i = 1;
int j = 0;
//printf("%d\n",nagtive(2));
int N;
scanf("%d",&N);
for(int m = 0; m < N; m ++){
scanf("%d",&num);
if(num % 5 == 0){
if(num % 2 == 0){
a1 ++;
A1 += num;
}
}else if(num % 5 == 1){
i ++;
num = num * nagtive(i);
A2 += num;
}else if(num % 5 == 2){
A3 ++;
}else if(num % 5 == 3){
//printf("num:%d A4:%0.1f j:%d\n",num,A4,j);
j ++;
float i = num;
A4 = A4 + i;
//printf("num:%d A4:%0.1f j:%d\n",num,A4,j);
}else{
if(num > A5)
A5 = num;
}
}
//printf("A4:%0.1f j:%d\n",A4,j);
if(j != 0){
float i = j;
A4 = A4 / i;
}
//printf("A4:%0.1f j:%d\n",A4,j);
if(a1 == 0)
printf("N ");
else
printf("%d ",A1);

if(i == 1)
printf("N ");
else
printf("%d ",A2);

if(A3 == 0)
printf("N ");
else
printf("%d ",A3);

if(j == 0)
printf("N ");
else
printf("%0.1f ",A4);

if(A5 == 0)
printf("N");
else
printf("%d",A5);

}
竟然忽视了题中是要求先输入数字的个数了，这种错都能有。