C语言程序设计题:从键盘输入100个整数,计算并输出大于等于零的数的平均数(保留小数点后两位)。

如题所述

第1个回答  2013-01-09
#include <stdio.h>
int main()
{
int i,tmp = 0,tot = 0;
double ans = 0;
for( i = 0 ; i < 100 ; i++)
{
scanf("%d",&tmp);
if( tmp > 0 )
{
ans += tmp;
tot++;
}
}
printf("%.2lf",ans/tot);
getch();
return 0;
}本回答被提问者采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网