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 |
输入数据出现了误差,哪位帮一下#include<stdio.h> int main() { int k,z,i,n,m,c[10000],a,b,j,max=0,sum=0; float l[10000]; scanf("%d%d",&n,&z); for(i=0;i<n;i++){ scanf("%f",&l[i]); c[i]=l[i]*100; if(c[i]>max) max=c[i]; sum=sum+c[i]; } a=sum/z; b=max/z; for(;a-b>1;){ j=(a+b)/2; for(k=0,m=0;k<n;k++) m=m+c[k]/j; if(m>=z) b=j; else a=j; } printf("%.2f",(float)b/100); return 0; } 我单步了一下,在c[]=l[]*100那个地方会出现误差,比如我输入8.04,l[]却是803,怎么回事呢,高手帮帮忙 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator