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 <iomanip>
#include <cmath>

// Vector 2D
template<class T>
struct Vec2D
{
    T x,y;
    explicit Vec2D(T x_=T(), T y_=T()):x(x_),y(y_){}
    Vec2D(const std::pair<T,T>& p):x(p.first),y(p.second){}
    Vec2D& operator+=(const Vec2D& v){ return *this = *this+v; }
    Vec2D& operator-=(const Vec2D& v){ return *this = *this-v; }
    friend Vec2D operator+(const Vec2D& l, const Vec2D& r){ return Vec2D(l.x+r.x,l.y+r.y); }
    friend Vec2D operator-(const Vec2D& l, const Vec2D& r){ return Vec2D(l.x-r.x,l.y-r.y); }
    friend T norm(const Vec2D& v){ return std::hypot(v.x,v.y); }
    friend T norm2(const Vec2D& v){ return v.x*v.x+v.y*v.y; }
    friend T dot(const Vec2D& l, const Vec2D& r){ return l.x*r.x+l.y*r.y; }
    friend T cross(const Vec2D& l, const Vec2D& r){ return l.x*r.y-l.y*r.x; }
    friend int dir(const Vec2D& l, const Vec2D& r)
    {
        // assert(norm2(l)!=0);
        const auto c = cross(l,r);
        if(c>0) return 1;
        if(c<0) return -1;
        if(dot(l,r)<0) return -2;
        if(norm2(l)<norm2(r)) return 2;
        return 0;
    }
};

// Triangle 2D
template<class T=double>
class Triangle2D
{
    Vec2D<T> a,b,c;
public:
    explicit Triangle2D(T ax=T(), T ay=T(), T bx=T(), T by=T(), T cx=T(), T cy=T()):a(ax,ay),b(bx,by),c(cx,cy){}
    Triangle2D(const Vec2D<T>& a_, const Vec2D<T>& b_, const Vec2D<T>& c_):a(a_),b(b_),c(c_){}
    T area() const
    {
        return std::abs(a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y))/2;
    }
    T dist_a() const { return norm(b-c); }
    T dist_b() const { return norm(c-a); }
    T dist_c() const { return norm(a-b); }
    Vec2D<T> circumcenter() const
    {
        const Vec2D<T> vb(2*(b.x-a.x),2*(c.x-a.x)),
                       vc(2*(b.y-a.y),2*(c.y-a.y)),
                       vd(norm2(a)-norm2(b),norm2(a)-norm2(c));
        return Vec2D<T>(cross(vc,vd)/cross(vb,vc),
                        cross(vd,vb)/cross(vb,vc));
    }
    T R() const { return dist_a()*dist_b()*dist_c()/(4*area()); }
};

static void solve()
{
    typedef double F;
    F x1,y1,x2,y2,x3,y3; std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    const Triangle2D<F> tri(x1,y1,x2,y2,x3,y3);
    auto c = tri.circumcenter();
    std::cout << c.x << " " << c.y << " " << tri.R() << std::endl;
}

int main()
{
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(3);
    int n; std::cin >> n;
    for(int i=0; i<n; ++i) solve();
}

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


class vec{
public:
	double x;
	double y;
	double normEXP2() const{
		return x*x + y*y;
	}
	vec& operator+(const vec& v){
		x += v.x;
		y += v.y;
		return *this;
	}
	vec& operator-(const vec& v){
		x -= v.x;
		y -= v.y;
		return *this;
	}
	vec& operator*(double scala){
		x *= scala;
		y *= scala;
		return *this;
	}
	double operator*(const vec& v) const{
		return x*v.x + y*v.y;
	}
};


istream& operator>>(istream& i, vec& v){
	i >> v.x >> v.y;
	return i;
}


pair<double, double> cramer(const vec& a, const vec& b){
	pair<double, double> solve;
	solve.first = (2 * a.normEXP2()*b.normEXP2() - 2 * b.normEXP2()*(a*b)) / (4 * a.normEXP2()*b.normEXP2() - 4 * ((a*b)*(a*b)));
	solve.second = (2 * a.normEXP2()*b.normEXP2() - 2 * a.normEXP2()*(a*b)) / (4 * a.normEXP2()*b.normEXP2() - 4 * ((a*b)*(a*b)));

	return solve;
}


int main(){
	int n;
	vec v1, v2, v3;
	vec b, c;
	vec solveVec;
	pair<double, double> solve;
	double x, y;
	double r;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> v1 >> v2 >> v3;
		b = v2 - v1;
		c = v3 - v1;
		
		solve = cramer(b, c);
		solveVec = (b*solve.first) + (c*solve.second);

		solveVec = v1 + solveVec;
		r = sqrt(solveVec.normEXP2());

		y = (double)((int)((solveVec.y * 1000) + 0.5)) / 1000;
		r = (double)((int)((r * 1000) + 0.5)) / 1000;
		x = (double)((int)((solveVec.x * 1000) + 0.5)) / 1000;

		printf("%.3lf %.3lf %.3lf\n", x, y, r);
	}

	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(3);
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        double x1, y1, x2, y2, x3, y3;
        cin>>x1>>y1>>x2>>y2>>x3>>y3;
        double m=(y1*(x2-x3)+y2*(x3-x1)+y3*(x1-x2))*2;
        double cx=(x1*x1+y1*y1)*(y2-y3) +(x2*x2+y2*y2)*(y3-y1) +(x3*x3+y3*y3)*(y1-y2);
        double cy=(x1*x1+y1*y1)*(x2-x3) +(x2*x2+y2*y2)*(x3-x1) +(x3*x3+y3*y3)*(x1-x2);
        double x=-cx/m;
        double y=cy/m;
        double r=sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y));
        cout<<x<<' '<<y<<' '<<r<<'\n';
    }
    return 0;
}

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 *= 1000;
    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 *= 1000;
    *xp = round(*xp);
    *xp /= 1000;
    
    *yp *= 1000;
    *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;
}