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<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
double zeti(double);
int main() {
	pair<double, double> a;
	pair<double, double> b;
	pair<double, double> c;
	pair<double, double> m1;
	pair<double, double> m2;
	double s1, s2,x1,y1,x2,y2,x,y,b1,b2;
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		x = -1000.0;
		y = -1000.0;
		b1 = 0.0;
		b2 = 0.0;
		s1 = -1000.0;
		s2 = -1000.0;
		scanf("%lf%lf", &a.first, &a.second);
		scanf("%lf%lf", &b.first, &b.second);
		scanf("%lf%lf", &c.first, &c.second);
		m1.first = (a.first + b.first) / 2.0;
		m1.second = (a.second + b.second) / 2.0;
		m2.first = (b.first + c.first) / 2.0;
		m2.second = (b.second + c.second) / 2.0;
		swap(m1.first, m1.second);
		swap(m2.first, m2.second);
		//x is qual
		if (a.first - b.first == 0) {
			x = m1.first;
			b1 = m1.first;
		}
		//y is qual
		else if (a.second - b.second == 0) {
			y = m1.second;

		}
		else {
			s1 = (zeti(a.second - b.second)) / (zeti(a.first - b.first));
			b1 = s1*m1.first - m1.second;
		}
		//x is qual
		if (b.first - c.first == 0) {
			x = m2.first;
			b2 = m1.first;
		}
		//y is qual
		else if (b.second - c.second == 0) {
			y = m2.second;
		}
		else {
			s2 = (zeti(c.second - b.second)) / (zeti(c.first - b.first));
			b2 = s2*m2.first - m2.second;
		}
			s1 = 1.0 / s1*-1.0;
			s2 = 1.0 / s2*-1.0;

		if (x == -1000.0) {
			x = (b1 - b2) / (s2 - s1);
		}
		if (y==-1000.0&&s1 ==0.001) {
			y = s2*x + b2;
		}
		else if(y == -1000.0&&s2 == 0.001) {
			y = s1*x + b1;
		}
		double r,w,e;
		w = zeti(a.first - x);
		e = zeti(a.second - y);
		r = sqrt(w*w+e*e);
		printf("%.3lf %.3lf %.3lf\n", x, y,r);

	}
	return 0;
}
double zeti(double center) {
	if (center < 0) {
		center *= -1;
	}
	return center;
}

C++: /*
A1＝2(X2?X1)
B1＝2(Y2?Y1)
C1＝X12?X22＋Y12?Y22
A2＝2(X3?X1)
B2＝2(Y3?Y1)
C2＝X12?X32＋Y12?Y32

X＝(B1C2?B2C1)/(A1B2?A2B1)
Y＝(C1A2?C2A1)/(A1B2?A2B1)
*/
#include <fstream>
#include <iostream>
#include <math.h>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#define PI 3.14159265
using namespace std;

int main() {
  // ifstream cin("../test.txt");
  int n;
  cin >> n;
  while (n--) {
    double x1,y1,x2,y2,x3,y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double a1 = 2 * (x2 - x1);
    double b1 = 2 * (y2 - y1);
    double c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
    double a2 = 2 * (x3 - x1);
    double b2 = 2 * (y3 - y1);
    double c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;

    double px = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
    double py = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);

    double r = sqrt((px - x1) * (px - x1) + (py - y1) * (py - y1));

    px += 0.0005;
    py += 0.0005;
    // r  += 0.0004;
    printf("%.3f %.3f %.3f\n", px, py, r);
  }
}

C++: #include<iostream>
#include<iomanip>
#include<cmath>
int main()
{
	int n;
	std::cin >> n;
	double**result = new double*[n];
	for(int i = 0; i < n; i++)
	{
		result[i] = new double[3];
		double x1, y1, x2, y2, x3, y3;
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double dx12 = x1 - x2, dx23 = x2 - x3, dx31 = x3 - x1, dy12 = y1 - y2, dy23 = y2 - y3, dy31 = y3 - y1;
		result[i][0] = (x1 * x1 * dy23 + x2 * x2 * dy31 + x3 * x3 * dy12 - dy12 * dy23 * dy31) / (x1 * dy23 + x2 * dy31 + x3 * dy12) / 2;
		result[i][1] = (y1 * y1 * dx23 + y2 * y2 * dx31 + y3 * y3 * dx12 - dx12 * dx23 * dx31) / (y1 * dx23 + y2 * dx31 + y3 * dx12) / 2;
		double dx = result[i][0] - x1, dy = result[i][1] - y1;
		result[i][2] = sqrt(dx * dx + dy * dy);
	}
	std::cout << std::fixed << std::setprecision(3);
	for(int i = 0; i < n; i++)
	{
		std::cout << result[i][0] << ' ' << result[i][1] << ' ' << result[i][2] << std::endl;
		delete[]result[i];
	}
	delete[]result;
	return 0;
}

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

double sqr( double x )
{
	return x * x;
}

int main()
{
	int n;
	std::cin >> n;

	while( n-- )
	{
		double x1, y1, x2, y2, x3, y3;
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		double a = x1 - x2, b = y1 - y2, c = -( sqr( x1 ) + sqr( y1 ) ) + ( sqr( x2 ) + sqr( y2 ) ),
			   d = x2 - x3, e = y2 - y3, f = -( sqr( x2 ) + sqr( y2 ) ) + ( sqr( x3 ) + sqr( y3 ) );

		double l = ( c * e - b * f ) / ( e * a - b * d ), m = ( c * d - a * f ) / ( b * d - a * e );
		double n = -( sqr( x1 ) + sqr( y1 ) + l * x1 + m * y1 );

		std::cout << std::fixed << std::setprecision( 3 );
		std::cout << -l / 2.0 << " " << -m / 2.0 << " " << sqrt( sqr( l ) + sqr( m ) - 4 * n ) / 2.0 << std::endl;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef complex<double> point;
typedef pair<point, point> line;
double cross(point a, point b){
  return imag(conj(a) * b);
}


point cross_point(line a, line b){
  double d1 = cross(b.second - b.first,
                    b.first - a.first);
  double d2 = cross(b.second - b.first,
                    a.second - a.first);
  return a.first + (a.second - a.first) * (d1/d2);
}

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    point x[3];
    for (int j = 0; j < 3; j++) {
      double real, imag;
      cin >> real >> imag;
      x[j] = point(real, imag);
    }
    point m1 = (x[0] - x[1]), m2 = (x[1] - x[2]);
    m1 = point(m1.real()/2, m1.imag()/2);
    m2 = point(m2.real()/2, m2.imag()/2);
    line n1 = line(m1*point(0, 1), m1*point(0, -1)),
      n2 = line(m2*point(0, 1), m2*point(0, -1));
    n1.first += m1 + x[1];
    n1.second += m1 + x[1];
    n2.first += m2 + x[2];
    n2.second += m2 + x[2];
    point center = cross_point(n1, n2);
    printf("%.3lf %.3lf %.3lf\n", center.real(), center.imag(),
           abs(center - x[0]));
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
	int n;
	double x1, x2, x3;
	double y1, y2, y3;
	cin >> n;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
	double px, py, r;
	double A = (x2 - x1)*(y3 - y2) - (y2 - y1)*(x3 - x2);
	px = 0.5*((y3 - y2)*(x2*x2 - x1*x1 + y2*y2 - y1*y1) - (y2 - y1)*(x3*x3 - x2*x2 + 
y3*y3 - y2*y2)) / A;
	py = 0.5*(-(x3 - x2)*(x2*x2 - x1*x1 + y2*y2 - y1*y1) + (x2 - x1)*(x3*x3 - x2*x2 + y3*y3 - y2*y2)) / A;
	double a = px - x1;
	double b = py - y1;
	double r0 = (a*a + b*b);
	double r1 = sqrt(r0);
	cout << fixed << setprecision(10) << px << " " << py << " " << r1 <<  endl;
}

C++: #include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
  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 xp = ((x1 * x1 + y1 * y1) * (y2 - y3) + (x2 * x2 + y2 * y2) * (y3 - y1)
      + (x3 * x3 + y3 * y3) * (y1 - y2)) / (2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)));
    double yp = ((x1 * x1 + y1 * y1) * (x2 - x3) + (x2 * x2 + y2 * y2) * (x3 - x1)
      + (x3 * x3 + y3 * y3) * (x1 - x2)) / (2 * (y1 * (x2 - x3) + y2 * (x3 - x1) + y3 * (x1 - x2)));
    double a = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    double b = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
    double c = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
    double r = a * b * c / (sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c)));
    cout << fixed << setprecision(3) << xp << " " << yp << " " << r << endl;
  }
}