#include
(30951)#include
int main()
{
int num;
int a[1000];
while(scanf("%d",&num)!=EOF)
{
int count = 0;
int countint =0;
float sum = 0;
for(int i =0;i {
scanf("%d",&a[i]);
if(a[i]<0)
{
count++;
}
if(a[i]>0)
{
countint++;
sum+=a[i];
}
}
printf("%d %0.1f\n",count,countint>0?sum/countint:0);
}
}
(30951)#include
int main()
{
int num;
int a[1000];
while(scanf("%d",&num)!=EOF)
{
int count = 0;
int countint =0;
float sum = 0;
for(int i =0;i
scanf("%d",&a[i]);
if(a[i]<0)
{
count++;
}
if(a[i]>0)
{
countint++;
sum+=a[i];
}
}
printf("%d %0.1f\n",count,countint>0?sum/countint:0);
}
}
「求助大佬帮看看这道算法题吧!」首先输入要输入的整数个数n,然后输入n个整数。输出为n个整数中负数的个数,和所有正整数的平均值,结果保留一位小数。 0即不是正整数,也不是负数,不计入计算。如果...
https://gw-c.nowcoder.com/api/sparta/jump/link?link=https%3A%2F%2Fwww.nowcoder.com%2Fpractice%2F6abde6ffcc354ea1a8333836bd6876b8
全部评论
相关推荐