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

这个题目有bug,double不能过,改成float了之后就过了

Posted by ElaxChin at 2011-08-07 16:27:21 on Problem 2350
#include <stdio.h>
#include <string.h>

#define N 1000

int main()
{
    int t, n;
	int A[N];
	scanf("%d",&t);
	while(t--) {
		memset(A, 0.0, sizeof(A));
		scanf("%d", &n);
		int i = 0;
		double sum = 0;
		int num = n;
		while(num--) {
		    scanf("%d",&A[i]);
			sum += A[i];
			i++;
		}
		double average = 0;
		average = sum / n;
		int count = 0;
		for (i = 0; i < n; i++) {
			if (A[i] > average) {
			    count++;
			}
		}
		printf("%.3f%%\n", (float)count*100/n);
	}
	return 0;
}

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