12月将举办首届西电ACM新生赛,敬请期待~~~~
Xidian Online Judge WebBoard
[ New Thread ]
Problem 1042 >> 网上copy的算法
heheda @ 2015-05-14 11:58:24
[ Quote ] [ Edit ] [ Delete ] 1#
算法和网上的一样,答案算出来也一样(不只是样例,测了其他多组数据),怎么一直显示答案错误?
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;


int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n;
double A[110];
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%lf",&A[i]);
}
int i;
sort(A,A+n);
for( i=0;i<n-1;i++)
{
A[i+1]=(A[i]+A[i+1])/2;
}
printf("%.2f\n",A[i]);
}
return 0;
}
13060410021 @ 2015-05-14 16:34:50
[ Quote ] [ Edit ] [ Delete ] 2#
我也不知道。。。。话说你最后是怎么过的?
heheda @ 2015-05-14 21:57:58
[ Quote ] [ Edit ] [ Delete ] 3#
精度问题,加eps
[Top] [Previous Page] [Next Page]
Anything about the Problems, Please Contact Admin:admin
All Copyright Reserved 2010-2014 Xidian ACM Online Judge TEAM
GPL2.0 2003-2014 HUSTOJ Project TEAM