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 nature_forever at 2007-08-16 19:30:54 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