从键盘输入10个整数到数组中,求其中正数的个数及其平均数,并输出结果.

[C语言】C++:从键盘输入10个整数到数组中,求其中正数的个数及其平均数,并输出结果。要求精确到小数点后两位。用#incula<stdio.h> void main()开头

#include <stdio.h>
void main()
{

int b=0,i,c[10];
float ave=0.00,sum=0.00;
for(i=0;i<10;i++)
{
scanf("%d",&c[i]);
sum=sum+c[i];
}
for(i=0;i<10;i++)
{
if(c[i]>0)
b=b+1;
}
ave=sum/10;
printf("正数的个数是%d个,平均数是%.2f ",b,ave);
}
温馨提示:答案为网友推荐,仅供参考
相似回答