Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

想法太单纯了……

Posted by frkstyc at 2005-10-13 21:04:27 on Problem 2646
In Reply To:麻烦看一下错哪了! Posted by:shiming413 at 2005-10-13 21:03:02
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator