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

Re:(附代码)数据都过了,但是GCC,G++不能过的注意了,把double改为float就能过,或者换成c++也就能过了

Posted by 129074016 at 2014-05-15 18:00:06 on Problem 1862
In Reply To:数据都过了,但是GCC,G++不能过的注意了,把double改为float就能过,或者换成c++也就能过了 Posted by:129074016 at 2014-05-15 17:59:32
> 把double改为float就能过,或者换成c++也就能过了
> #include<stdio.h>
> #include<stdlib.h>
> #include<math.h>
> int cmp ( const void *a , const void *b )
> {
>     return *(float *)b - *(float *)a;
> }
> 
> int main()
> {
> 	float s,a[1000];
> 	int n,i;
> 	while(scanf("%d",&n)!=EOF)
> 	{
> 		for(i=0;i<n;i++)
> 		{
> 			scanf("%f",&a[i]);
> 		}
> 		qsort(a,n,sizeof(a[0]),cmp);
> 		s=a[0];
> 		for(i=1;i<n;i++)
> 		{
> 			s=2.0*sqrt(s*a[i]);
> 		}
> 		printf("%.3f\n",s);
> 	}
> }

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