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<iomanip>
#include<cmath>
using namespace std;

int main(){

	int n;
	double x1, y1, x2, y2, x3, y3;
	double la, lb, lc;
	double a, b, c;
	
	double r;
	double px, py;

	cin >> n;

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

		lc = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
		la = (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3);
		lb = (x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1);

		a = fabs((atan2( y2 - y1, x2 - x1 ) - atan2( y3 - y1, x3 - x1 )));
		b = fabs((atan2( y1 - y2, x1 - x2 ) - atan2( y3 - y2, x3 - x2 )));
		c = fabs((atan2( y1 - y3, x1 - x3 ) - atan2( y2 - y3, x2 - x3 )));

		r = sqrt(la) / (sin(a)*2);
		px = ( sin(2*a) * x1 + sin(2*b) * x2 + sin(2*c) * x3 ) / (sin(2*a)+sin(2*b)+sin(2*c));
		py = ( sin(2*a) * y1 + sin(2*b) * y2 + sin(2*c) * y3 ) / (sin(2*a)+sin(2*b)+sin(2*c));

		r = floor(r*1000+0.5)/1000;
		px = floor(px*1000+0.5)/1000;
		py = floor(py*1000+0.5)/1000;

		cout << setprecision(3) << fixed  << px << " " << py << " " << r << endl;

	}
	return 0;
}

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

int main(void){
    double n, x1, x2, x3, y1, y2, y3, Px, Py, r;
    cin >> n;
    
    for(int i=1; i<=n; i++){
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    
        Px = ( (x1*x1 + y1*y1 - x3*x3 - y3*y3) / (2 * (y1-y3)) - (x2*x2 + y2*y2 - x3*x3 - y3*y3) / (2 * (y2-y3)) ) / ( (x1-x3)/(y1-y3) - (x2-x3)/(y2-y3) );
        Py = -(x1-x3) / (y1-y3) * Px + (x1*x1 + y1*y1 - x3*x3 - y3*y3) / (2 * (y1-y3));
        
        r = sqrt((x1-Px)*(x1-Px) + (y1-Py)*(y1-Py));

        cout << fixed << setprecision(3) << Px << " " << Py << " " << r << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <bitset>
#include <cmath>
#include <complex>

#define EPS 1e-6
using namespace std;

double cross(complex<double> a, complex<double> b)
{
  return a.real() * b.imag() - a.imag() * b.real();
}

double dot(complex<double> a, complex<double> b)
{
  return a.real() * b.real() + a.imag() * b.imag();
}

int main()
{
  complex<double> coor[3];
  int N;
  scanf(" %d ", &N);
  for (int i = 0; i < N; i++) {
    for (int i = 0; i < 3; i++) {
      double x, y;
      scanf(" %lf %lf ", &x, &y);
      coor[i] = complex<double>(x, y);
      //printf("coor[%d](%.3lf, %.3lf)\n", i ,coor[i].real(), coor[i].imag());
    }
    complex<double> h[2], d[2];
    for (int j = 0; j < 2; j++) {
      h[j] = complex<double>((coor[j].real() + coor[j + 1].real()) / 2, (coor[j].imag() + coor[j + 1].imag()) / 2);
      d[j] = complex<double>(coor[j].real() - coor[j + 1].real(), coor[j].imag() - coor[j + 1].imag());
    }
    double D = cross(d[0], d[1]);
    complex<double>o(cross( complex<double>( dot( d[0], h[0] ) , dot( d[1], h[1] ) ), complex<double>( d[0].imag(), d[1].imag() ) ) / D,
					cross( complex<double>( d[0].real(), d[1].real() ), complex<double>( dot( d[0], h[0] ) , dot( d[1], h[1] ) ) ) / D);
    //printf("h1(x, y) = (%.3lf, %.3lf), h2(x, y) = (%.3lf, %.3lf), d1(x, y) = (%.3lf, %.3lf), d2(x, y) = (%.3lf, %.3lf), o(x, y) = ( %.3lf, %.3lf)\n", h[0].real(), h[0].imag(), h[1].real(), h[1].imag(), d[0].real(), d[0].imag(), d[1].real(), d[1].imag(), o.real(), o.imag());
    complex<double> t = o - coor[0];
    double r = abs(t);
    if (abs(o.real()) < EPS) {o = complex<int>(abs(o.real()), o.imag());}
    if (abs(o.imag()) < EPS) {o = complex<int>(o.real(), abs(o.imag()));}
    printf("%.3lf %.3lf %.3lf\n", o.real(), o.imag(), r);    
  }
  return 0;
}

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

int main() {
  int n = 0;
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    float x1, y1, x2, y2, x3, y3;
    scanf("%f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3);

    // x^2 + y^2 + lx + my + n = 0

    float A[3][3] = { {x1, y1, 1}, {x2, y2, 1}, {x3, y3, 1} };
    // detA = a00a11a22 + a10a21a02 + a20a01a12 - a00a21a12 - a20a11a02 - a10a01a22
    float detA =
        A[0][0] * A[1][1] * A[2][2]
      + A[1][0] * A[2][1] * A[0][2]
      + A[2][0] * A[0][1] * A[1][2]
      - A[0][0] * A[2][1] * A[1][2]
      - A[2][0] * A[1][1] * A[0][2]
      - A[1][0] * A[0][1] * A[2][2];

    assert(detA != 0);
    float invA[3][3] = {
        { (A[1][1] * A[2][2] - A[1][2] * A[2][1]) / detA,
          (A[0][2] * A[2][1] - A[0][1] * A[2][2]) / detA,
          (A[0][1] * A[1][2] - A[0][2] * A[1][1]) / detA },
        { (A[1][2] * A[2][0] - A[1][0] * A[2][2]) / detA,
          (A[0][0] * A[2][2] - A[0][2] * A[2][0]) / detA,
          (A[0][2] * A[1][0] - A[0][0] * A[1][2]) / detA },
        { (A[1][0] * A[2][1] - A[1][1] * A[2][0]) / detA,
          (A[0][1] * A[2][0] - A[0][0] * A[2][1]) / detA,
          (A[0][0] * A[1][1] - A[0][1] * A[1][0]) / detA }
    }; 

    float b[3] = {-(x1 * x1 + y1 * y1), -(x2 * x2 + y2 * y2), -(x3 * x3 + y3 * y3)};
    
    float l = invA[0][0] * b[0] + invA[0][1] * b[1] + invA[0][2] * b[2];
    float m = invA[1][0] * b[0] + invA[1][1] * b[1] + invA[1][2] * b[2];
    float n = invA[2][0] * b[0] + invA[2][1] * b[1] + invA[2][2] * b[2];
      
    // (x + l/2)^2 - l^2/4 + (y + m/2)^2 - m^2/4 + n = 0;
    // (x, y) = (-l/2, -m/2)
    // r = sqrt(l^2/4 + m^2/4 - n)
    float px = -l / 2;
    float py = -m / 2;
    float r = std::sqrt(l * l / 4.0 + m * m / 4.0 - n);
    
    printf("%.3f %.3f %.3f\n", px, py, r);
  }
}

C++: #include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>
#include <map>
#include <math.h>
#include <utility>


#pragma warning(disable:4996)
using namespace std;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;
const double PI = 3.141592653589793238;
const Int INF = 999999999999;
typedef pair<int, int> P;


double A[2][2];
double C[2];


int main()
{
	int n;
	cin >> n;
	REP(i, n){
		double x1, x2, x3, y1, y2, y3;
		cin >> x1>> x2 >> x3 >> y1 >> y2 >> y3;

		double x21 = x2 - x1;
		double x31 = x3 - x1;
		double y21 = y2 - y1;
		double y31 = y3 - y1;

		double xc = ((y31*(x21*x21 + y21*y21)) - (y21*(x31*x31 + y31*y31))) /
			(2 * (x21*y31 - y21*x31));

		double yc = ((x21*(x31*x31 + y31*y31)) - (x31*(x21*x21 + y21*y21))) /
			(2 * (x21*y31 - y21*x31));	
		
		double d = (xc - x1)*(xc - x1) + (yc - y1)*(yc - y1);
		int xc_ = xc * 1000;
		int yc_ = yc * 1000;
		xc_ += (xc_ % 10) > 4 ? 10 : 0;
		yc_ += (yc_ % 10) > 4 ? 10 : 0;

		printf("%.3lf %.3lf %.3lf", xc, yc, sqrt(d));


	}

}