PAT乙级1012数字分类,有一个测试点不过,求改正后通过的代码
```c
#include<stdio.h>
#include<stdlib.h>
int main()
{
int n, * p = NULL, i, A1 = 0, A2 = 0, A3 = 0, A5 = 0, t = 1,count=0,flag=1;
double A4=0;
scanf("%d", &n);
p = malloc(n * sizeof(int));
for (i = 0; i < n; ++i)
{
scanf("%d", p + i);
switch (*(p + i)%5)
{
case 0:
{
if (*(p + i) % 2 == 0)
A1 += *(p + i);
break;
}
case 1:A2 += *(p + i) * t; t *= -1; break;
case 2:++A3; break;
case 3:A4 += 1.0 * *(p + i); ++count; flag = 0; break;
default:
{
if (A5 < *(p + i))
A5 = *(p + i);
break;
}
}
}
A4 = A4 / (1.0 * count);
if (A1 == 0)
printf("N");
else
printf("%d", A1);
if (A2 == 0)
printf(" N");
else
printf(" %d", A2);
if (A3 == 0)
printf(" N");
else
printf(" %d", A3);
if (flag==1)
printf(" N");
else
printf(" %.1lf", A4);
if (A5 == 0)
printf(" N");
else
printf(" %d", A5);
}
https://blog.csdn.net/weixin_44562957/article/details/104056442 看下这个吧 参考下这个链接https://blog.csdn.net/weixin_44562957/article/details/104056442
页:
[1]