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 <cmath>

using namespace std;
typedef struct { double x; double y;} point;
 
point getCircumcenter(point a, point b, point c)
{
    double A1 = 2 * ( b.x - a.x );
    double B1 = 2 * ( b.y - a.y );
    double C1 = pow(a.x,2)-pow(b.x,2) + pow(a.y,2)-pow(b.y,2);
    double A2 = 2 * ( c.x - a.x );
    double B2 = 2 * ( c.y - a.y );
    double C2 = pow(a.x,2)-pow(c.x,2) + pow(a.y,2)-pow(c.y,2);
    double X = (B1 * C2 - B2 * C1) / (A1 * B2 - A2 * B1);
    double Y = (C1 * A2 - C2 * A1) / (A1 * B2 - A2 * B1);
	point P;
	P.x=X;
	P.y=Y;
    return P;
}

double getTwoPointDictance(point a, point b)
{
	return fabs(sqrt(pow((a.x-b.x),2)+pow((a.y-b.y),2)));
}
double AntiMinusZero(double n)
{
	if(n=0)
	{
		return 0.0f;
	}
	return n;
}

int main()
{
    int n;
    cin>>n;
    point a,b,c;
    while(n--)
	{
        cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y;
        point ans = getCircumcenter(a,b,c);
        printf("%.3lf %.3lf %.3lf", AntiMinusZero(ans.x), AntiMinusZero(ans.y), getTwoPointDictance( a, ans));
    }
}

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

using namespace std;

int main() {
    int n;

    scanf("%d", &n);

    double x1, y1, x2, y2, x3, y3;

    while (n--) {
        scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
 
        if (y1 == y3) {
            swap(x3, x2);
            swap(y3, y2);
        }

        if (y2 == y3) {
            swap(x3, x1);
            swap(y3, y1);
        }

        double a = x2 - x3;
        double b = y2 - y3;
        double c = x2 + x3;
        double d = y2 + y3;
        double e = x3 - x1;
        double f = y3 - y1;
        double g = x3 + x1;
        double h = y3 + y1;
        double ab = a / b;
        double d2 = d / 2.0;
        double c2 = c / 2.0;
        double ef = e / f;

        double px = (ab * c2 + d2 - ef * (g / 2) - h / 2) / (ab - ef);
        double py = -ab * px + ab * c2 + d2;
        double x = x1 - px;
        double y = y1 - py;
        double r = sqrt(x * x + y * y);

        printf("%.3lf %.3lf %.3lf\n", px, py, r);
    }

    return 0;
}

C++: // 入力された3点を通る円の中心座標と半径を求める。

#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main(void) {
    double x1, y1, x2, y2, x3, y3;
    double ox, oy, r;
    int n;
    
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        
        ox = ((y2 - y3)*(x1*x1 - x2*x2 + y1*y1 - y2*y2) - (y1 - y2)*(x2*x2 - x3*x3 + y2*y2 - y3*y3))
             / (2*((x1 - x2)*(y2 - y3) - (x2 - x3)*(y1 - y2)));
        if(y1 != y2) {
            oy = ((x1*x1 - x2*x2 + y1*y1 - y2*y2) - 2*(x1 - x2)*ox) / (2 * (y1 - y2));
        }else {
            oy = ((x2*x2 - x3*x3 + y2*y2 - y3*y3) - 2*(x2 - x3)*ox) / (2 * (y2 - y3));
        }
        
        r = sqrt((ox - x1)*(ox - x1) + (oy - y1)*(oy - y1));
        
        printf("%.3lf %.3lf %.3lf", ox, oy, r);
        cout << endl;
    }
}

C++: #include <iostream>
#include <math.h>
using namespace std;

int main(){

	double x1,y1,x2,y2,x3,y3,x,y;
	double a1,a2,b1,b2,c1,c2;
	int n,i;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		a1 = 2*(x2-x1);
		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;
		x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
		y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
		printf("%.3f %.3f %.3f\n",x,y,sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1)));
	}

	return 0;
}

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

double det(double a, double b, double c, double d, double e, double f, double g, double h, double i){
	double delta;
	double m[3][3] = {{a, b, c},{d, e, f},{g, h, i}};
	delta = m[0][0]*m[1][1]*m[2][2];
	delta += m[2][0]*m[0][1]*m[1][2];
	delta += m[0][2]*m[1][0]*m[2][1];
	delta -= m[0][2]*m[1][1]*m[2][0];
	delta -= m[0][0]*m[1][2]*m[2][1];
	delta -= m[2][2]*m[0][1]*m[1][0];
	return delta;
}

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		double x1, y1, x2, y2, x3, y3, x, y, r;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double d0 = det(x1, y1, 1, x2, y2, 1, x3, y3, 1);
		double d1 = det((-((x1*x1)+(y1*y1))), y1, 1, (-((x2*x2)+(y2*y2))), y2, 1, (-((x3*x3)+(y3*y3))), y3, 1);
		double d2 = det(x1, (-((x1*x1)+(y1*y1))), 1, x2, (-((x2*x2)+(y2*y2))), 1, x3, (-((x3*x3)+(y3*y3))), 1);
		double d3 = det(x1, y1, (-((x1*x1)+(y1*y1))), x2, y2, (-((x2*x2)+(y2*y2))), x3, y3, (-((x3*x3)+(y3*y3))));
		double l, m, n;
		l = d1 / d0;
		m = d2 / d0;
		n = d3 / d0;
		x = -(l / 2);
		y = -(m / 2);
		r = sqrt((l*l + m*m - (4*n)) / 4);
		printf("%.3f %.3f %.3f\n", x, y, r);
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cmath>

using namespace std;

//-------------------------------------------------------------------------
// geometric library

struct point {
	double x;
	double y;
};

struct circle {
	point center;
	double radius;
};

double get_distance(const point& p1, const point& p2)
{
	return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}

point get_midpoint(const point& p1, const point& p2)
{
	point mid;
	mid.x = p1.x + p2.x / 2.0;
	mid.y = p1.y + p2.y / 2.0;
	return mid;
}

std::istream& operator >> (std::istream& is, point& p)
{
	is >> p.x >> p.y;
	return is;
}

//-------------------------------------------------------------------------
// solution

// 外接円を求める
circle get_circum_circle(const point& p1, const point& p2, const point& p3)
{
	double a = get_distance(p1, p2);
	double b = get_distance(p2, p3);
	double c = get_distance(p3, p1);
	circle result;

	// 半径の公式
	result.radius = a * b * c / sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));

	// c,p1,p2のなす角
	double theta = acos((a / 2.0) / result.radius);

	result.center.x = p1.x + result.radius * cos(theta);
	result.center.y = p1.y + result.radius * sin(theta);

	return result;
}

circle get_circum_circle(istream& is)
{
	point p1, p2, p3;
	is >> p1 >> p2 >> p3;
	return get_circum_circle(p1, p2, p3);
}

int main(void)
{
	int num_cases;

	std::cin >> num_cases;

	for (int i = 0; i < num_cases; i++) {		
		circle result = get_circum_circle(std::cin);
		printf("%.3f %.3f %.3f\n", result.center.x, result.center.y, result.radius);
	}
	return 0;
}