题目在这里1206
#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdio.h>
using namespace std;
int main()
{
int nProb, n;
double pos[11], pos_x, pos_y;
cin >> nProb;
for (int i = 1; i <= nProb; i++)
{
cin >> n;
for (int j = 0; j < n; j++)
{
cin >> pos[j];
}
sort(pos, pos + n);
pos_x = (pos[n - 1] + pos[0]) / 2;
pos_y = 1.0;
for (int j = 0; j < n - 1; j++)
{
pos_y += sqrt(4 - pow((pos[j+1] - pos[j])/2, 2));
}
printf("%d: %.4lf %.4lf\n", i, pos_x, pos_y);
}
//system("pause");
return 0;
}