| ||||||||||
| 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 | |||||||||
Re:小弟很菜,望大牛帮忙看一下错在哪里?In Reply To:小弟很菜,望大牛帮忙看一下错在哪里? Posted by:smark at 2007-03-04 23:33:17 > #include<iostream.h>
> #include<math.h>
> #include<stdio.h>
>
> int main()
> {
> int t,a[101];
> double res;
> cin>>t;
> if(t>1)
> {
> for(int i=0;i<t;i++)
> {
> cin>>a[i];
> }
>
> for(i=0;i<=t-1;i++)
> {
> for(int j=t;j>=i+1;j--)
> {
> if(a[j]>a[j-1])
> {
> int temp;
> temp=a[j];
> a[j]=a[j-1];
> a[j-1]=temp;
> }
> }
> }//排序有问题
> res=2*sqrt(a[0]*a[1]);
> if(t>2)
> {
> for(i=2;i<t;i++)
> {
> res=2*sqrt(res*a[i]);
> }
> }
> printf("%.3f\n",res);
> }
> else if(t==1)
> {
> cin>>res;
> printf("%.3f\n",res);
> }
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator