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 abilitytao at 2008-08-16 16:25:57 on Problem 1862
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int cmp(const void *a,const void *b)
{
	return ((*(double*)a)>(*(double*)b))?1:-1;
}

int main()
{
	int n,i,j;
	double a[101];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%f",&a[i]);//把这里的f改成lf就对了,为什么呀,有区别么?
	if(n==1)
	{
		printf("%.3f\n",a[0]);
		return 0;
	}
	qsort(a,n,sizeof(a[0]),cmp);
	for(i=n-2;i>=0;i--)
	{
		a[i]=2*sqrt(a[i]*a[i+1]);
	}

	printf("%.3f\n",a[0]);
	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