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>

using namespace std;

int main() {
	int c;
	double x1, y1, x2, y2, x3, y3;
	double px, py, r;
	double e1, e2, e3;
	double l, m, n;

	cout << fixed << setprecision(3);
	cin >> c;
	for (int i = 0; i < c; ++i) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		e1 = - pow(x1, 2) - pow(y1, 2);
		e2 = - pow(x2, 2) - pow(y2, 2);
		e3 = - pow(x3, 2) - pow(y3, 2);

		l = (e1 * y2+ e2 * y3+ e3 * y1- e1 * y3- e2 * y1- e3 * y2)/ (x1 * y2+ x2 * y3+ x3 * y1- x1 * y3- x2 * y1- x3 * y2);
		m = (x1 * e2+ x2 * e3+ x3 * e1- x1 * e3- x2 * e1- x3 * e2)/ (x1 * y2+ x2 * y3+ x3 * y1- x1 * y3- x2 * y1- x3 * y2);
		n = (x1 * y2 * e3 + x2 * y3 * e1 - x3 * y1 * e2 - x1 * y3 * e2 - x2 * y1 * e3 - x3 * y2 * e1)/ (x1 * y2+ x2 * y3+ x3 * y1- x1 * y3- x2 * y1- x3 * y2);

		px = - l / 2;
		py = - m / 2;
		r = sqrt(pow(px, 2) + pow(py, 2) - n);

		cout << px << " " << py << " " << r << endl;
	}

	return 0;
}

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

struct Zahyou
{
	float x, y;
};

int main()
{
	int n;
	Zahyou de[4];

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 1; j < 4; j++)
		{
			scanf("%f %f", &de[j].x, &de[j].y);
		}
		de[0].x = ((de[1].y - de[3].y)*(pow(de[1].y, 2) - pow(de[2].y, 2) + pow(de[1].x, 2) - pow(de[2].x, 2)) + (de[1].y - de[2].y)*(pow(de[1].y, 2) - pow(de[3].y, 2) + pow(de[1].x, 2) - pow(de[3].x, 2))) / (2 * (de[1].y - de[3].y)*(de[1].x - de[2].x) + 2 * (de[1].y - de[2].y)*(de[1].x - de[3].x));
		de[0].y = ((de[1].x - de[3].x)*(pow(de[1].x, 2) - pow(de[2].x, 2) + pow(de[1].y, 2) - pow(de[2].y, 2)) + (de[1].x - de[2].y)*(pow(de[1].x, 2) - pow(de[3].x, 2) + pow(de[1].y, 2) - pow(de[3].y, 2))) / (2 * (de[1].x - de[3].x)*(de[1].y - de[2].y) + 2 * (de[1].x - de[2].x)*(de[1].y - de[3].y));
		
		printf("%.3f %.3f %.3f\n",de[0].x,de[0].y,sqrt(pow((de[0].x-de[1].x),2)+pow((de[0].y-de[1].y),2)));
	}
	return 0;
}

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

int main(){
    int n;
    double x1, x2, x3, y1, y2, y3, x, y;
    cin >> n;
    for(int i = 0;i < n;i++){
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
	if(y1 == y2)swap(x1, x3), swap(y1, y3);
	else if(y1 == y3)swap(x1, x2), swap(y1, y2);
	double x = (x3-x1)/(y1-y3)*(x1+x3)/2-(x2-x1)/(y1-y2)*(x1+x2)/2+(y1+y2)/2-(y1+y3)/2;
	x /= ((x3-x1)/(y1-y3) - (x2-x1)/(y1-y2));
	double y = (x2-x1)/(y1-y2)*(x - x1+x2/2) + (y1+y2)/2;
	cout << x << " " << y << " " << hypot(x1-x,y1-y) << endl;   
    }
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
using namespace std;
int main( void )
{
	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;

		for ( int j = 0; j < 3; j++ )
		{
			swap( x1, x2 );
			swap( y1, y2 );
			swap( x2, x3 );
			swap( y2, y3 );

			double a = 2.0 * x1 - 2.0 * x2;
			double b = 2.0 * y1 - 2.0 * y2;
			double c = 2.0 * x2 - 2.0 * x3;
			double d = 2.0 * y2 - 2.0 * y3;

			if ( a * b - c * d == 0.0 )
				continue;

			double e = x1 * x1 - x2 * x2 + y1 * y1 + y2 * y2;
			double f = x2 * x2 - x3 * x3 + y2 * y2 + y3 * y3;

			double x0 = ( d * e - b * f ) / ( a * b - c * d );
			double y0 = ( a * f - c * e ) / ( a * b - c * d );

			if ( x0 == -0.0 )
				x0 = 0.0;
			if ( y0 == -0.0 )
				y0 = 0.0;

			double r1 = sqrt( (x1-x0)*(x1-x0) + (y1-y0)*(y1-y0) );
			double r2 = sqrt( (x2-x0)*(x2-x0) + (y2-y0)*(y2-y0) );
			double r3 = sqrt( (x3-x0)*(x3-x0) + (y3-y0)*(y3-y0) );

			cout.setf( ios::fixed, ios::floatfield );
			cout << setprecision(3);
			if ( r1 == r2 && r1 == r3 )
				cout << x0 << " " << y0 << " " << r1 << endl;
		}

	}
	return 0;
}

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

using namespace std;

int main() {
	double x[3], y[3];
	double a, b, c;
	double A[2], B[2], C[2];
	double px, py;
	double r;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];
		A[0] = 2 * (x[1] - x[0]);
		B[0] = 2 * (y[1] - y[0]);
		C[0] = pow(x[0], 2) - pow(x[1], 2) + pow(y[0], 2) - pow(y[1], 2);
		A[1] = 2 * (x[2] - x[0]);
		B[1] = 2 * (y[2] - y[0]);
		C[1] = pow(x[0], 2) - pow(x[2], 2) + pow(y[0], 2) - pow(y[2], 2);
		px = ((B[0] * C[1]) - (B[1] * C[0])) / ((A[0] * B[1]) - (A[1] * B[0]));
		py = ((C[0] * A[1]) - (C[1] * A[0])) / ((A[0] * B[1]) - (A[1] * B[0]));
		a = sqrt(pow(x[1] - x[0], 2) + pow(y[1] - y[0], 2));
		b = sqrt(pow(x[2] - x[0], 2) + pow(y[2] - y[0], 2));
		c = sqrt(pow(x[2] - x[1], 2) + pow(y[2] - y[1], 2));
		r = (a * b * c) / sqrt((a+b+c) * (-a+b+c) * (a-b+c) * (a+b-c));
		printf("%.3lf %.3lf %.3lf\n", px, py, r);
	}
	return 0;
}