| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:学长学姐们帮忙看一下到底哪儿错了?In Reply To:学长学姐们帮忙看一下到底哪儿错了? Posted by:200802007038 at 2009-11-08 00:01:12 > #include<stdio.h>
> void main()
> {
> float a[12];double b=0;
> int i;
> for(i=0;i<12;i++)
> scanf("%.2f",&a[i]);
> for(i=0;i<12;i++)
> printf("%f\n",a[i]);
> for(i=0;i<=11;i++)
> b+=a[i];
> b=b/12;
> printf("$%.2f\n",b);
> }
输入不要那么些 全部最后都统一用double 输出你多余了
#include<stdio.h>
int main()
{
double a[12];
double b=0;
int i;
for (i=0;i<12;i++)
scanf("%lf",&a[i]);
/*for(i=0;i<12;i++)
printf("%lf\n",a[i]);*/
for (i=0;i<=11;i++)
b+=a[i];
b=b/12;
printf("$%.2f\n",b);
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator