| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
100道纪念下,虽然水但因为一开始理解错误,WA好多次!!(附代码)#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator