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 catoran at 2005-06-11 11:28:19 on Problem 1477
#include<stdio.h>
void main(){
	int a[1000],n,i,average,sum,mnum,count=0;

	while(1){
		scanf("%d",&n);
		if(n==0)    return;
		else {
		
			count++;
			sum=0;

			for(i=0;i<n;i++){
				scanf("%d",&a[i]);				
				sum+=a[i];
			}

			average=sum/n;
			mnum=0;
			
			for(i=0;i<n;i++){
				if(a[i]>average)
					mnum+=(a[i]-average);
				}
			
			if(count>1)  printf("\n");
			printf("Set #%d\nThe minimum number of moves is %d.\n",count,mnum);

		}
	}
}

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