51Testing软件测试论坛
标题:
PAT乙级1012数字分类,有一个测试点不过,求改正后通过的代码
[打印本页]
作者:
测试积点老人
时间:
2021-8-26 11:15
标题:
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);
}
复制代码
作者:
海海豚
时间:
2021-8-27 09:14
https://blog.csdn.net/weixin_44562957/article/details/104056442
看下这个吧
作者:
bellas
时间:
2021-8-27 09:36
参考下这个链接
https://blog.csdn.net/weixin_44562957/article/details/104056442
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2