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

Re:这个printf("%.3lf%%\n", (double)count*100/n)就不能过了 但是printf("%.3f%%\n", (float)count*100/n)可以过

Posted by ElaxChin at 2011-08-07 16:31:24 on Problem 2350
In Reply To:Re:这个也可以过 Posted by:ElaxChin at 2011-08-07 16:29:34
#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 > 0.000001) {
			    count++;
			}
		}
		printf("%.3lf%%\n", (double)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