Go: package main

import (
	"fmt"
	"math"
)

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

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

func circleTriangle() {
	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 <cmath>
#include <iomanip>

using namespace std;

    // 半径取得の処理
double getR(double x1, double y1, double x2, double y2, double x3, double y3) {
    
    double marginX1, marginX2, marginX3;
    double marginY1, marginY2, marginY3;
    double a, b, c;
    double r, s;
    
        // それぞれのxとyの長さを求める
    marginX1 = abs(x2 - x1);
    marginY1 = abs(y2 - y1);
    marginX2 = abs(x1 - x3);
    marginY2 = abs(y1 - y3);
    marginX3 = abs(x3 - x2);
    marginY3 = abs(y3 - y2);
    
        // それぞれの辺の長さを求める
    a = sqrt(pow(marginX1,2) + pow(marginY1,2));
    b = sqrt(pow(marginX2,2) + pow(marginY2,2));
    c = sqrt(pow(marginX3,2) + pow(marginY3,2));
    
        // 半径を求める
    s = (a + b + c) / 2;
    r = (a * b * c) / (4 * sqrt(s * (s - a) * (s - b) * (s - c)));
    
    r *= 10000;
    r = (int)r;
    r /= 10;
    r = round(r);
    r /= 1000;
    
    return r;
}

    // 中心座標を求める処理
void getCentralCoodinate(double x1, double y1, double x2, double y2, double x3, double y3, double *xp, double *yp) {
    
    double marginX1, marginX2;
    double marginY1, marginY2;
    double marginXp1, marginXp2;
    double marginYp1, marginYp2;
    double n, m;
    
        // 初期化
    *xp = 0;
    *yp = 0;
    
        // それぞれのxとyの長さを求める
    marginX1 = abs(x2 - x1);
    marginY1 = abs(y2 - y1);
    marginX2 = abs(x1 - x3);
    marginY2 = abs(y1 - y3);
    
        // 中心座標を求めるのに必要な式
    marginXp1 = 2 * marginX1;
    marginYp1 = 2 * marginY1;
    marginXp2 = 2 * marginX2;
    marginYp2 = 2 * marginY2;
    
    n = pow(x1,2) - pow(x2,2) + pow(y1,2) - pow(y2,2);
    m = pow(x1,2) - pow(x3,2) + pow(y1,2) - pow(y3,2);
    
    *xp = (marginYp1 * m - marginYp2 * n) / (marginXp1 * marginYp2 - marginXp2 * marginYp1);
    *yp = (marginXp2 * n - marginXp1 * m) / (marginXp1 * marginYp2 - marginXp2 * marginYp1);
    
    *xp *= 10000;
    *xp = (int)*xp;
    *xp /= 10;
    *xp = round(*xp);
    *xp /= 1000;
    
    *yp *= 10000;
    *yp = (int)*yp;
    *yp /= 10;
    *yp = round(*yp);
    *yp /= 1000;
}

    // main処理
int main(void) {
    double x1, x2, x3;
    double y1, y2, y3;
    double xp, yp;
    double r;
    int n;
    
    cin >> n;
    
    while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3) {
        
            // 半径と中心座標を取得する処理
        r = getR(x1, y1, x2, y2, x3, y3);
        getCentralCoodinate(x1, y1, x2, y2, x3, y3, &xp, &yp);
        
            // 出力
        cout << showpoint << setprecision(4);
        cout << xp << " " << yp << " " << r << endl;
    }
    
    return 0;
}

C++: #include <stdio.h>
#include <complex>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef complex<double> P;

double cross(const P& a, const P& b) { return imag(conj(a)*b); }
P rot90(const P& p) { return p*P(0, 1); }
P crosspoint(const P& l0, const P& l1, const P& m0, const P& m1) {
    const double A = cross(l1-l0, m1-m0);
    const double B = cross(l1-l0, l1-m0);
    return m0 + B/A * (m1-m0);
}

P center(P a, P b, P c) {
    const P m1 = 0.5*(a+b), m2 = 0.5*(b+c);
    return crosspoint(m1, m1+rot90(b-a), m2, m2+rot90(c-b));
}

int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
        double x1, y1, x2, y2, x3, y3;
        scanf("%lf%lf", &x1, &y1);
        scanf("%lf%lf", &x2, &y2);
        scanf("%lf%lf", &x3, &y3);
        const P p = center(P(x1, y1), P(x2, y2), P(x3, y3));
        printf("%.3f %.3f %.3f\n", p.real(), p.imag(), abs(p-P(x1, y1)));
    }
    return 0;
}

C++: #include <stdio.h>
#include <math.h>

int main(void)
{
	float x[3][2];
	int n;
	int xa, xb, xc;
	int ya, yb, yc;
	float ans[3];
	int i, j;
	
	scanf("%d", &n);
	
	while (n){
		for (i = 0; i < 3; i++){
			for (j = 0; j < 2; j++){
				scanf("%f", &x[i][j]);
			}
		}
		
		xa = 2 * (x[1][0] - x[0][0]);
		xb = 2 * (x[1][1] - x[0][1]);
		xc = x[0][0] * x[0][0] - x[1][0] * x[1][0] + x[0][1] * x[0][1] - x[1][1] * x[1][1];
		ya = 2 * (x[2][0] - x[0][0]);
		yb = 2 * (x[2][1] - x[0][1]);
		yc = x[0][0] * x[0][0] - x[2][0] * x[2][0] + x[0][1] * x[0][1] - x[2][1] * x[2][1];
		
		ans[0] = (xb * yc - yb * xc) / (xa * yb - ya * xb);
		ans[1] = (xc * ya - yc * xa) / (xa * yb - ya * xb);
		ans[2] = sqrt((ans[0] - x[0][0]) * (ans[0] - x[0][0]) + (ans[1] - x[0][1]) * (ans[1] - x[0][1]));
		
		for (i = 0; i < 3; i++){
			if (i){
				printf(" ");
			}
			printf("%.3f", ans[i]);
		}
		printf("\n");
		
		n--;
	}
	
	return (0);
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
	int n;
	double x1, y1, x2, y2, x3, y3;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double x12, y12, x13, y13;
		x12 = (x1 + x2) / 2.0;
		y12 = (y1 + y2) / 2.0;
		x13 = (x1 + x3) / 2.0;
		y13 = (y1 + y3) / 2.0;
		double vx12, vy12, vx13, vy13;
		vx12 = x2-x1;
		vy12 = y2-y1;
		vx13 = x3-x1;
		vy13 = y3-y1;
		double x, y;
		x = (vx12*vy13*x12-vx13*vy12*x13+vy12*vy13*(y13-y12))/(vx12*vy13-vx13*vy12);
		y = y13 - vx13*(x-x13)/vy13;
		double r;
		r = sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
		printf("%.3f %.3f %.3f\n", x, y, r);
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
        int n;
        double a,b,c,d,e,f;
        double x1,x2,x3,y1,y2,y3;
        double px,py;
        double r;

        cin >> n;

        for(int i=0;i<n;i++){
                cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
                a = (x2-x1)*2.0;
                b = (y2-y1)*2.0;
                c = (x2*x2 + y2*y2 - x1*x1 - y1*y1);
                d = (x3-x1)*2.0;
                e = (y3-y1)*2.0;
                f = (x3*x3 + y3*y3 - x1*x1 - y1*y1);
                px = (c*e-b*f)/(a*e-b*d);
                py = (a*f-c*d)/(a*e-b*d);
                r = sqrt((px-x1)*(px-x1) + (py-y1)*(py-y1));
                printf("%.3f %.3f %.3f\n",px,py,r);



        }

        return 0;
}

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

using namespace std;

int main()
{
    int num;
    cin >> num;
    double x1, x2, x3, y1, y2, y3;
    double px, py, r;

    for(int i = 0; i < num; ++i)
    {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        px = (1 / 2.0) * ((x1 * x1 + y1 * y1) * (y3 - y2) + (x2 * x2 + y2 * y2) * (y1 - y3)
            + (x3 * x3 + y3 * y3) * (y2 - y1)) / (x1 * (y3 - y1) + x2 * (y1 - y3) + x3 * (y2 - y1));
        py = -(x3 - x2) / (y3 - y2) * px + (1 / 2.0) * (x3 * x3 - x2 * x2 + y3 * y3 - y2 * y2) / (y3 - y2);
        r = sqrt((x1 - px) * (x1 - px) + (y1 - py) * (y1 - py));

        cout << fixed << setprecision(3) << px << " " << py << " " << r << endl;
    }
}

C++: #include<iostream>
#include<string>
#include <iomanip>
using namespace std;
int main() {
	int n;
	cin >> n;
	float x1, y1, x2, y2, x3, y3;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

	float px, py, r;
	float A1, B1, C1, A2, B2, C2;
	A1 = 2 * (x2 - y2);
	B1 = 2*(y2 - y1);
	C1 = x1*x1 - x2*x2 + y1*y1 - y2*y2;
	A2 = 2 * (x3 - x1);
	B2 = 2 * (y3 - y1);
	C2 = x1*x1 - x3*x3 + y1*y1 - y3*y3;
	
	px = (B1*C2 - B2*C1) / (A1*B2 - A2*B1);
	py = (C1*A2 - C2*A1) / (A1*B2 - A2*B1);

	r = sqrt((x1-px)*(x1-px)+(y1-py)*(y1-py));

	px = round(px * 1000) / 1000;
	py = round(py * 1000) / 1000;
	r = round(r * 1000) / 1000;
	cout <<fixed << setprecision(4) << px << " ";
	cout << fixed << setprecision(4) << py << " ";
	cout<< fixed << setprecision(4) << r << endl;

	return 0;

}