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

小弟很菜,望大牛帮忙看一下错在哪里?

Posted by smark at 2007-03-04 23:33:17 on Problem 1862
#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:
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