Go: package main

import (
	"fmt"
	"math"
)

func main() {
	n := scanInt()
	for i := 0; i < n; i++ {
		cal()
	}
}

func scanInt() int {
	var n int
	fmt.Scanf("%d", &n)
	return n
}

func cal() {
	var x1, y1, x2, y2, x3, y3 float64
	fmt.Scanf("%f%f%f%f%f%f", &x1, &y1, &x2, &y2, &x3, &y3)
	a := 2 * (x1 - x2)
	b := 2 * (y1 - y2)
	c := 2 * (x1 - x3)
	d := 2 * (y1 - y3)
	e := x1*x1 - x2*x2 + y1*y1 - y2*y2
	f := x1*x1 - x3*x3 + y1*y1 - y3*y3

	px := (d*e - b*f) / (a*d - b*c)
	py := (a*f - c*e) / (a*d - b*c)

	r := math.Sqrt((x1-px)*(x1-px) + (y1-py)*(y1-py))
	fmt.Printf("%.3f %.3f %.3f\n", px, py, r)
}

C++: #include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main(){
  double x1,y1,x2,y2,x3,y3;
  vector<double> x1l,y1l,x2l,y2l,x3l,y3l;
  int n;

  cin >> n;

  for(int i=0; i<n; i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    x1l.push_back(x1);
    y1l.push_back(y1);
    x2l.push_back(x2);
    y2l.push_back(y2);
    x3l.push_back(x3);
    y3l.push_back(y3);
  }

  double ex,ey,fx,fy;
  double a,b,c,d,e,f,r;
  double cx,cy;

  for(int i=0; i<n; i++){
    x1=x1l[i];
    y1=y1l[i];
    x2=x2l[i];
    y2=y2l[i];
    x3=x3l[i];
    y3=y3l[i];

    a = x1*x1+y1+y1;
    b = x2*x2+y2+y2;
    c = x3*x3+y3+y3; 
    d = 0.5/(x1*y2-x2*y1+x2*y3-x3*y2+x3*y1-x1*y3);
    e = d*(a*y2-b*y1+b*y3-c*y2+c*y1-a*y3);
    f = d*(x1*b-x2*a+x2*c-x3*b+x3*a-x1*c);
    r = sqrt((e-x1)*(e-x1)+(f-y1)*(f-y1));
    printf("%0.3f %0.3f %0.3f\n",e,f,r);
  }

  r

C++: #include <iostream>
#include <cmath>
#include <cstdio>

int main()
{
	int n;
	std::cin >> n;
	for(int i = 0; i < n; ++i)
	{
		double x1,y1,x2,y2,x3,y3;
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		double const a = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));	
		double const b = sqrt((x3-x2)*(x3-x2) + (y3-y2)*(y3-y2));
		double const c = sqrt((x3-x1)*(x3-x1) + (y3-y1)*(y3-y1));

		double const cosA = (b*b+c*c-a*a)/(2*b*c);
		double const cosB = (a*a+c*c-b*b)/(2*a*c);
		double const cosC = (a*a+b*b-c*c)/(2*a*b);
		double const sinA = sqrt(1-cosA*cosA);

		double const r = a / (sinA * 2);
		//std::cout << "r = " << r << std::endl;

		std::cout << "cosA = " << cosA << std::endl;
		std::cout << "cosB = " << cosB << std::endl;
		std::cout << "cosC = " << cosC << std::endl;

		if(-0.001 < cosA && cosA < 0.001) std::printf("%.3lf %.3lf", (x1+x2) / 2 , (y1+y2) / 2);
		else if (-0.001 < cosB && cosB < 0.001) std::printf("%.3lf %.3lf", (x2+x3) / 2 ,(y2+y3) / 2);
		else if (-0.001 < cosC && cosC < 0.001) std::printf("%.3lf %.3lf", (x1+x3) / 2 , (y1+y3) / 2);
		else
		{
			double const h = sqrt(r*r-(c/2)*(c/2));
				
			//std::cout << "c = " << c << std::endl;
			//std::cout << "h = " << h << std::endl;
			
			double const xm = (x1+x3)/2;
			double const ym = (y1+y3)/2;
			//std::cout << "xm = " << xm << " ym = " << ym << std::endl;

			double const sinD = (y1-y3) / sqrt((x3-x1)*(x3-x1) + (y3-y1)*(y3-y1));
			double const cosD = (x1-x3) / sqrt((x3-x1)*(x3-x1) + (y3-y1)*(y3-y1));
			//std::cout << "sinD = " << sinD << " cosD = " << cosD << std::endl;

			double const y = h / cosD;
			double const x = y * sinD;

			double const xd = xm + x;
			double const yd = ym + y;

			//std::cout << xd << " " << yd;
		}
		std::printf(" %.3lf\n", r);
		return 0;
	}
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

double sisya(double a) {
	a *= 1000.0;
	//cout << a << endl;
	a += 0.5;
	a = (int)a;
	a /= 1000.0;
	return a; 
}

double ll(double x1, double y1, double x2, double y2) {
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		double x[3], y[3];
		for (int j = 0; j < 3; j++) {
			cin >> x[j] >> y[j];
		}
		double a1, a2, b1, b2, c1, c2;
		a1 = 2.0 * (x[1]-x[0]);
		a2 = 2.0 * (x[2]-x[0]);
		b1 = 2.0 * (y[1]-y[0]);
		b2 = 2.0 * (y[2]-y[0]);
		c1 = x[0]*x[0]-x[1]*x[1]+y[0]*y[0]-y[1]*y[1];
		c2 = x[0]*x[0]-x[2]*x[2]+y[0]*y[0]-y[2]*y[2];
		double X, Y, R;
		X = (b1*c2-b2*c1)/(a1*b2-a2*b1);
		Y = (c1*a2-c2*a1)/(a1*b2-a2*b1);
		R = ll(X, Y, x[0], y[0]);
		X = sisya(X);
		Y = sisya(Y);
		R = sisya(R);
		printf("%.3f %.3f %.3f\n", X, Y, R);
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
	int c;
	double x1, y1, x2, y2, x3, y3;
	double px, py, r;
	double e1, e2, e3;
	double l, m, n;

	cout << fixed << setprecision(3);
	cin >> c;
	for (int i = 0; i < c; ++i) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		e1 = - pow(x1, 2) - pow(y1, 2);
		e2 = - pow(x2, 2) - pow(y2, 2);
		e3 = - pow(x3, 2) - pow(y3, 2);

		l = (e1 * y2 + e2 * y3 + e3 * y1 - e1 * y3 - e2 * y1 - e3 * y2)/ (x1 * y2 + x2 * y3 + x3 * y1 - x1 * y3 - x2 * y1 - x3 * y2);
		m = (x1 * e2 + x2 * e3 + x3 * e1 - x1 * e3 - x2 * e1 - x3 * e2)/ (x1 * y2 + x2 * y3 + x3 * y1 - x1 * y3 - x2 * y1 - x3 * y2);
		n = (x1 * y2 * e3 + x2 * y3 * e1 - x3 * y1 * e2 - x1 * y3 * e2 - x2 * y1 * e3 - x3 * y2 * e1)/ (x1 * y2 + x2 * y3 + x3 * y1 - x1 * y3 - x2 * y1 - x3 * y2);

		px = - l / 2;
		py = - m / 2;
		r = sqrt(pow(px, 2) + pow(py, 2) - n);

		px *= 1000; px = round(px); px /= 1000; if (px == -0) px = 0;
		py *= 1000; py = round(py); py /= 1000; if (py == -0) py = 0;
		 r *= 1000;  r = round(r);   r /= 1000; if ( r == -0)  r = 0;

		cout << px << " " << py << " " << r << endl;
	}

	return 0;
}

C++: 
#include <iostream>
#include <cstdio>
#include <complex>
#include <cmath>

using namespace std;

typedef complex<double> Point;

bool eqv(double d1, double d2) {
    return abs(d1-d2) < 1e-4;
}

double r_(double x) {
    if(abs(x) < 0.001) return 0;
    return x;
}

int main() {
    int N;
    double x1, x2, x3, y1, y2, y3;

    cin >> N;
    while(N--) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Point p1(x1, y1), p2(x2, y2), p3(x3, y3);

        double R = abs(abs(p3-p2) / sin(arg(p2-p1) - arg(p3-p1))) / 2;
        Point pc1 = (p1+p2) / 2.;
        Point ph1 = (pc1-p1) * Point(0, 1);
        Point pc2 = (p1+p3) / 2.;
        Point ph2 = (pc2-p1) * Point(0, 1);

        Point d = pc2-pc1;
        double ratio = ph2.real() / ph2.imag();
        double a = (d.real()-d.imag()*ratio) / (ph1.real()-ph1.imag()*ratio);
        Point center = pc1 + ph1 * a / abs(ph1);

        /*
        int i1 = (int)center.real(), d1 = ((int)((center.real()-i1)*10000)+5)/10;
        int i2 = (int)center.imag(), d2 = ((int)((center.imag()-i2)*10000)+5)/10;
        int i3 = (int)R, d3 = ((int)((R-i3)*10000)+5)/10;
        printf("%d.%03d %d.%03d %d.%03d\n", i1, d1, i2, d2, i3, d3);
        */
        printf("%.3f %.3f %.3f\n", r_(center.real()), r_(center.imag()), r_(R));
    }
    return 0;
}

C++: #include<stdio.h>
#include<math.h>
double sisyagonyuu3(double moto){
	if(moto>0){
		return (moto+0.0005)/100*100;
	}else if(moto==0){
		return 0;
	}else{
		return (moto-0.0005)/100*100;
	}
}
int main()
{
	int n;
	double x1[32],x2[32],x3[32],y1[32],y2[32],y3[32],p,q,r;
	double ac,ab,bc,a,b,c;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lf%lf%lf%lf%lf%lf",&x1[i],&x2[i],&x3[i],&y1[i],&y2[i],&y3[i]);
		p=sisyagonyuu3(((y1[i]-y3[i])*(y1[i]*y1[i]-y2[i]*y2[i]+x1[i]*x1[i]-x2[i]*x2[i])-(y1[i]-y2[i])*(y1[i]*y1[i]-y3[i]*y3[i]+x1[i]*x1[i]-x3[i]*x3[i])));
		p/=(2*(y1[i]-y3[i])*(x1[i]-x2[i])-2*(y1[i]-y2[i])*(x1[i]-x3[i]));
		q=sisyagonyuu3(((x1[i]-x3[i])*(x1[i]*x1[i]-x2[i]*x2[i]+y1[i]*y1[i]-y2[i]*y2[i])-(x1[i]-x2[i])*(x1[i]*x1[i]-x3[i]*x3[i]+y1[i]*y1[i]-y3[i]*y3[i])));
		q/=(2*(x1[i]-x3[i])*(y1[i]-y2[i])-2*(x1[i]-x2[i])*(y1[i]-y3[i]));
		ab=sqrt(fabs((x3[i]-x1[i])*(x3[i]-x1[i])+(y3[i]-y1[i])*(y3[i]-y1[i])));
		ac=sqrt(fabs((x3[i]-x2[i])*(x3[i]-x2[i])+(y3[i]-y2[i])*(y3[i]-y2[i])));
		bc=sqrt(fabs((x2[i]-x1[i])*(x2[i]-x1[i])+(y2[i]-y1[i])*(y2[i]-y1[i])));
		a=bc;
		b=ac;
		c=ab;
		r=a*b*c/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
		printf("%.3lf %.3lf %.3lf\n",p,q,r);
	}
	return 0;
}
/*?????\???*/