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

100道纪念下,虽然水但因为一开始理解错误,WA好多次!!(附代码)

Posted by 1008063102 at 2011-07-28 17:29:14 on Problem 1862
#include<stdio.h>
#include<math.h>
main()
{
  int n,i,j;
  double a[110],temp;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
  	scanf("%lf",&a[i]);
  }
  if(n==1)
  printf("%.3lf\n",a[0]);
  else
  {
   for(i=0;i<n-1;i++)
  {
   	 for(j=i+1;j<n;j++)
  	 {
	  if(a[i]>a[j])
	  {
  		temp=a[i];
	  a[i]=a[j];
	  a[j]=temp;
   	  }	
     }
   } 
   for(i=n-2;i>=0;i--)
   {
    a[i]=2*sqrt(a[i]*a[i+1]); 
   } 
   printf("%.3lf\n",a[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