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 <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;   // 許容誤差。問題によって変える
typedef complex<double> P; // Point
//点の座標は複素数で持つ
#define X real()
#define Y imag()
namespace std
{
bool operator<(const P p1, const P p2)
{
    return p1.X != p2.X ? p1.X < p2.X : p1.Y < p2.Y;
}
P operator+(const P p1, const P p2) { return P(p1.X + p2.X, p1.Y + p2.Y); }
P operator-(const P p1, const P p2) { return P(p1.X - p2.X, p1.Y - p2.Y); }
P operator*(const P p, double k) { return P(p.X * k, p.Y * k); }
P operator/(const P p, double k) { return P(p.X / k, p.Y / k); }
} // namespace std
//ここまで写経必須

//Segment/L
struct Segment
{
    P p1, p2;
    Segment() {}
    Segment(P p1, P p2) : p1(p1), p2(p2) {}
};
typedef Segment L;

//Circle
struct Circle
{
    P p;
    double r;
    Circle(const P &p, double r) : p(p), r(r) {}
};
typedef Circle C;

//ノルム
//二点a,bを投げるとノルムの2乗(a1-b1)^2+(a2-b2)^2を返す
double norm(P &p1, P &p2)
{
    return (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);
}

//外積cross(a,b) = |a||b|sinθ=a1b2-a2b1
//二点a,bを投げると外積を返す
double cross(const P &a, const P &b)
{
    return (conj(a) * b).Y;
}

//内積dot(a,b) = |a||b|cosθ=a1b1+a2b2
//二点a,bを投げると内積を返す
double dot(const P &a, const P &b)
{
    return (conj(a) * b).X;
}

//射影
//L(又はS)と点Pを投げるとLへPを射影した座標を返す
//依存:dot,norm
P Projection(L l, P p)
{
    P base = l.p2 - l.p1;                        //始点
    double r = dot(p - l.p1, base) / norm(base); //線分に対する倍率の計算
    return l.p1 + base * r;
}

//鏡映
//L(又はS)と点Pを投げるとLを軸としたPの鏡像座標を返す
//依存:Projection,dot,norm
P Reflection(L l, P p)
{
    return p + (Projection(l, p) - p) * 2.0;
}

//位置関係判定(線分abを軸にcがどちら側にあるか)
//三点a,b,cを投げることで，a-bを軸として
//時計回りの場合:1,反時計回りの場合:-1,c-a-bの並び:2,a-b-cの並び:-2
//その他（重なってる等）:0
//依存:cross,dot,norm
int ccw(P a, P b, P c)
{
    b -= a;
    c -= a; //aからの向きを考える
    if (cross(b, c) > EPS)
        return +1; //clockwise
    else if (cross(b, c) < -EPS)
        return -1; //counter clockwise
    else if (dot(b, c) < -EPS)
        return +2; //c-a-b
    else if (norm(b) < norm(c))
        return -2; //a-b-c
    else
        return 0; //他
}

//Intersection Determination
//L,S,Pそれぞれのペアの交差判定，PPは直接比較できるのでないです
//それぞれのペアを投げる,引数の順番は関数名に記載
//交差又は含まれている場合true,そうでない場合falseを返す

//依存:cross
bool intersectLL(const L &l, const L &m)
{
    return abs(cross(l.p2 - l.p1, m.p2 - m.p1)) > EPS || // non-parallel
           abs(cross(l.p2 - l.p1, m.p1 - l.p1)) < EPS;   // same L
}
//依存:cross
bool intersectLS(const L &l, const L &s)
{
    return cross(l.p2 - l.p1, s.p1 - l.p1) * // s.p1 is left of l
               cross(l.p2 - l.p1, s.p2 - l.p1) <
           EPS; // s.p2 is right of l
}
//依存:cross
bool intersectLP(const L &l, const P &p)
{
    return abs(cross(l.p2 - p, l.p1 - p)) < EPS;
}
//依存:ccw,cross,dot,norm
bool intersectSS(const L &s, const L &t)
{
    return ccw(s.p1, s.p2, t.p1) * ccw(s.p1, s.p2, t.p2) <= 0 &&
           ccw(t.p1, t.p2, s.p1) * ccw(t.p1, t.p2, s.p2) <= 0;
}

bool intersectSP(const L &s, const P &p)
{
    return abs(s.p1 - p) + abs(s.p2 - p) - abs(s.p2 - s.p1) < EPS; // triangle inequality
}

//distance
//L,S,Pについてペアを投げるとその距離を計算
//引数の順番は関数名参照

//依存:Projection,dot,norm
double distanceLP(const L &l, const P &p)
{
    return abs(p - Projection(l, p));
}
//依存:intersectLL,cross,distanceLP,Projection,dot,norm
double distanceLL(const L &l, const L &m)
{
    return intersectLL(l, m) ? 0 : distanceLP(l, m.p1);
}
//依存:intersectLS,cross,distanceLP,Projection,dot,norm
double distanceLS(const L &l, const L &s)
{
    if (intersectLS(l, s))
        return 0;
    return min(distanceLP(l, s.p1), distanceLP(l, s.p2));
}
//依存:intersectSP,Projection,dot,norm
double distanceSP(const L &s, const P &p)
{
    const P r = Projection(s, p);
    if (intersectSP(s, r))
        return abs(r - p);
    return min(abs(s.p1 - p), abs(s.p2 - p));
}
//依存:intersectSS,ccw,cross,dot,norm,distanceSP,intersectSP,Projection
double distanceSS(const L &s, const L &t)
{
    if (intersectSS(s, t))
        return 0;
    return min(min(distanceSP(s, t.p1), distanceSP(s, t.p2)),
               min(distanceSP(t, s.p1), distanceSP(t, s.p2)));
}

double distancePP(const P &p1, const P &p2)
{
    return abs(p1 - p2);
}
//二本のL(又はS)を投げると交点座標を返す
//一致している場合は一本目のp1を返します
//交わっていない場合はfalseを返します
//依存:cross
P crosspoint(const L &l, const L &m)
{
    double A = cross(l.p2 - l.p1, m.p2 - m.p1);
    double B = cross(l.p2 - l.p1, l.p2 - m.p1);
    if (abs(A) < EPS && abs(B) < EPS)
        return l.p1; // same line
    if (abs(A) < EPS)
        assert(false); // !!!PRECONDITION NOT SATISFIED!!!
    return m.p1 + B / A * (m.p2 - m.p1);
}

long long Manhattan(const vector<pair<P,P>> &seg,vector<P> &cp){
    int count = 0;
    for (int i = 0; i < seg.size();i++){
        L li = L(seg[i].first, seg[i].second);
        for (int j = i + 1; j < seg.size();j++){
            L lj = L(seg[j].first, seg[j].second);
            if(intersectSS(li,lj)){
                cp.push_back(crosspoint(li,lj));
                count++;
            }
        }
        if(i+2==seg.size())
            break;
    }
    return count;
}
//外接円
//点を三つ投げると中心点と半径が出る

pair<P, double> circumcircle(const P &p, const P &q, const P &r){
    double a=p.X,b=p.Y,c=q.X,d=q.Y,e=r.X,f=r.Y;
    double aa = a * a, bb = b * b, cc = c * c,dd = d * d, ee = e * e, ff = f * f;
    double cx,cy = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee - ff)) / (2 * (e - a) * (b - d) - 2 * (c - a) * (b - f));
    if(c==a){
        cx = (2 * (b - f) * cy - aa - bb + ee + ff) / (2 * (e - a));
    }else{
        cx = (2 * (b - d) * cy - aa - bb + cc + dd) / (2 * (c - a));
    }
    P ans = P(cx, cy);
    double R = abs(ans - p);
    return make_pair(ans, R);
}

int main(){
    int n;
    cin >> n;
    
    for (int i = 0; i < n;i++){
        double x1, x2, y1, y2,x3,y3;
        cin >> x1 >> y1 >> x2 >> y2>>x3>>y3;
        P a = P(x1, y1), b = P(x2, y2), c = P(x3, y3);
        pair<P,double> ans=circumcircle(a,b,c);
        double x = ans.first.X, y = ans.first.Y;
        x = round(x * 1000) / 1000;
        y = round(y * 1000) / 1000;
        ans.second = round(ans.second * 1000) / 1000;
        printf("%.3f %.3f %.3f\n", x,y, ans.second);
    }

    return 0;
}

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

using namespace std;

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

long double ll(long double x1, long double y1, long double x2, long 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++) {
		long double x[3], y[3];
		for (int j = 0; j < 3; j++) {
			cin >> x[j] >> y[j];
		}
		long 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];
		long 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;
}