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 |
遇到一个奇怪的问题,请大家帮帮忙,很简单的#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator