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> void main() { int n,all,average,anstemp; float *c,ans; do { scanf("%d",&n); if(n==0) break; anstemp=0; all=0; c=new float[n]; for(int i=0;i<n;i++) { scanf("%f",&c[i]); c[i]=c[i]*100;//将它们以美分计算 all+=int(c[i]); } average=all/n; if(2*(all%n)>=n)//四舍五入 average++; for(i=0;i<n;i++) if(c[i]>average) anstemp+=int(c[i]-average); ans=float(anstemp)/100;//化为美元 printf("%s%.2f\n","$",ans); delete []c; }while(1); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator