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 <complex>
#include <iostream>
#include <vector>

using namespace std;

struct complex_triangle{
    complex<double> a,b,c;

    complex_triangle(complex<double> &_a, complex<double> &_b, complex<double> &_c){
        a = _a;b = _b;c = _c;
    }
    
    double edge_lenth(int x){ //x= 0->bc, 1->ca, 2->ab  
        if(x==0) return abs(b-c);
        else if(x==1) return abs(c-a);
        else if(x==2) return abs(a-b);
    }

    double area(){
        complex<double> A = b - c, B = c - a;
        return abs(A.real()*B.imag() - A.imag()*B.real())/2;
    }

    double o_radi(){
        double ret = 1;
        for(int i=0;i<3;i++) ret *= edge_lenth(i);
        return ret/(4*area());
    }

    complex<double> o_cent(){ //外心
        complex<double> B = b - a, C = c - a,ret;
        double ss = (B.real()*C.imag() - B.imag()*C.real())*2;
        ret.real((C.imag()*norm(B) - B.imag()*norm(C))/ss);
        ret.imag((B.real()*norm(C) - C.real()*norm(B))/ss);
        ret += a;
        return ret;
    }
};

void solve(){
    double x1,x2,y1,y2,z1,z2;
    cin >> x1 >> x2 >> y1 >> y2 >> z1 >> z2;
    complex<double> x(x1, x2),y(y1, y2), z(z1, z2);
    complex_triangle da(x, y, z);
    complex<double> p = da.o_cent();
    //cout << da.area() << endl;
    printf("%.03f %.03f %.03f\n", p.real(), p.imag(), da.o_radi());
}

int main(){
    int n;cin >> n;
    for(int i = 0; i< n;i++) solve();
}

C++: #include<iostream>
#include<math.h>
using namespace std;
int main() {
	float x1, x2, x3, px, y1, y2, y3, py,r;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		if (y1 == y2) {
			px = (x1 + x2) / 2;
			py = (x1 - x3)*(x2 - x3) / (2 * (y3 - y1)) + (y1 + y3) / 2;
		}
		else if (y1 == y3) {
			px = (x1 + x3) / 2;
			py = (x1 - x2)*(x3 - x2) / (2 * (y2 - y1)) + (y1 + y2) / 2;
		}
		else {
			px = ((x1*x1 - x2*x2) / (y2 - y1) - (x1*x1 - x3*x3) / (y3 - y1) + y3 - y2) / (2 * ((x1 - x2) / (y2 - y1) - (x1 - x3) / (y3 - y1)));
			py = (px - (x1 + x2) / 2)*(x1 - x2) / (y2 - y1) + (y1 + y2) / 2;
		}
		r = sqrt((px - x1)*(px - x1) + (py - y1)*(py - y1));
		px = float(int(1000 * px + 0.5)) / 1000;
		py = float(int(1000 * py + 0.5)) / 1000;
		r = float(int(1000 * r + 0.5)) / 1000;
		cout << px << " " << py << " " << r << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <iomanip>
#define sqr(n) ((n) * (n))
using namespace std;

void equation(double a, double b, double c, double d, double e, double f, double *x, double *y)
{
  *x = (c * e - b * f) / (a * e - b * d);
  *y = (a * f - c * d) / (a * e - b * d);   
}

int main()
{
  int n;
  double x1, y1, x2, y2, x3, y3, x, y;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    x = y = 0;
    equation((2 * (x2 - x1)), (2 * (y2 - y1)), (sqr(x2) + sqr(y2) - sqr(x1) - sqr(y1)), (2 * (x3 - x2)), (2 * (y3 - y2)), (sqr(x3) + sqr(y3) - sqr(x2) - sqr(y2)), &x, &y);
    cout << fixed << setprecision(3) << x + 0.0001 << ' ' <<  y + 0.0001 << ' ' << sqrt(sqr(x1 - x) + sqr(y1 - y)) << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main() {

	int n;
	double x1, x2, x3, y1, y2, y3;
	double X, Y, R;
	double a, b, c, d, e, f;

	cin >> n;

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

		a = x2 - x1;
		b = x3 - x1;
		c = y2 - y1;
		d = y3 - y1;
	
		X = 0.5*(a*a*d - b*b*c) / (a*d - b*c) + (c*d*(d - c) / 2);
		Y = -b*(X - b / 2) / d+d/2;
		R = sqrt((X - x1)*(X - x1) + (Y - y1)*(Y - y1));

		/*?°???°????¬¬??????????????¨?????\
		if (X > 0)
			X = (int)(X * 1000 + 0.5);
		else X = (int)(X * 1000 - 0.5);

		if (Y>0)
			Y = (int)(Y * 1000 + 0.5);
		else Y = (int)(Y * 1000 - 0.5);

		if (R < 0)
			R = -R;
		R = (int)(R * 1000 + 0.5);

		*/
		printf("%.3f %.3f %.3f\n", X , Y , R );
	}
	return 0;
}

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

int main()
{
	int n;
	double x1,y1,x2,y2,x3,y3,xp,xp1,xp2,yp1,yp2,yp,r;
	scanf("%d",&n);

	for(int x=0;x<n;x++)
	{
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
		xp1=(y1-y3)*(y1*y1 -y2*y2 +x1*x1 -x2*x2) -(y1-y2)*(y1*y1 -y3*y3 +x1*x1 -x3*x3);
		xp2=2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3);
		xp=xp1/xp2;
		yp1=(x1-x3)*(x1*x1 -x2*x2 +y1*y1 -y2*y2) -(x1-x2)*(x1*x1 -x3*x3 +y1*y1 -y3*y3);
		yp2=2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3);
		yp=yp1/yp2;

		r=(x3-xp)*(x3-xp)+(y3-yp)*(y3-yp);
		r=sqrt(r);
		printf("%.3f %.3f %.3f",xp,yp,r);
	}
	return 0;
}