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

用double可以过的

Posted by linmeng at 2005-07-17 09:02:12 on Problem 2350
#include <iostream.h>
#include <stdio.h>
int c;
long n;
long a[1000];
int main()
 {
  cin>>c;
  while (c)
   {
    c--;
    cin>>n;
    int i;
    long sum=0;
    for (i=1;i<=n;i++)
     {
      cin>>a[i];
      sum+=a[i];
     }
    double xb=(double)sum/(double)n;
    long t=0;
    for (i=1;i<=n;i++)
     {
      if (a[i]>xb) t++;
     }
    xb=(double)t/(double)n*100;
    printf("%.3lf%c\n",xb,'%'); 
   }
  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