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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <numeric>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
double dx1, dx2, dx3, dy1, dy2, dy3;

int main(){
	cin >> n;
	REP(i, n){
		cin >> dx1 >> dy1 >> dx2 >> dy2 >> dx3 >> dy3;
		double a = 2 * (dx1 - dx2), b = 2 * (dy1 - dy2), c = (dx1*dx1 + dy1*dy1) - (dx2*dx2 + dy2*dy2);
		double d = 2 * (dx2 - dx3), e = 2 * (dy2 - dy3), f = (dx2*dx2 + dy2*dy2) - (dx3*dx3 + dy3*dy3);
		cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl;
		double x, y;
		//if (a < 0){
		//	a = -a;
		//	b = -b;
		//	c = -c;
		//}
		if (d < 0){
			d = -d;
			e = -e;
			f = -f;
		}
		if (a == 0){
			y = c / b;
			x = (f - e*y) / d;
		}
		else if (b == 0){
			x = c / a;
			if (d == 0) y = f / e;
			else y = (f - e*x) / d;
		}
		else if (a != 0 && b != 0){
			x = (b*f - c*e) / (b*d - a*e);
			y = (c*d - a*f) / (b*d - a*e);
		}
		printf("%.3lf %.3lf %.3lf\n", x, y, sqrt((dx1 - x)*(dx1 - x) + (dy1 - y)*(dy1 - y)));
	}
}

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

int main(void){
	int n, i, j;
	double x1,y1,x2,y2,x3,y3, px, py;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
		py = ((x3 - x1) * (pow(x2,2.0) - pow(x1,2.0) + pow(y2,2.0) - pow(y1,2.0)) - (x2 - x1) * (pow(x3,2.0) - pow(x1,2.0) + pow(y3,2.0) - pow(y1,2.0))) / (2 * ((y2 - y1) * (x3 - x1) - (y3 - y1) * (x2 - x1)));
		px = ((y3 - y1) * (pow(y2,2.0) - pow(y1,2.0) + pow(x2,2.0) - pow(x1,2.0)) - (y2 - y1) * (pow(y3,2.0) - pow(y1,2.0) + pow(x3,2.0) - pow(x1,2.0))) / (2 * ((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)));
		printf("%f %f %f\n",px,py,sqrt(pow(px - x1,2.0) + pow(px - x1,2.0)));
	}
	return 0;
}

C++: #include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int n;
  double x[3],y[3];
  double a[2],b[2],c[2];
  double xa,ya;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      scanf("%lf %lf",&x[j],&y[j]);
    }
    for(int j=1;j<3;j++){
      a[j-1]=2*(x[j]-x[0]);
      b[j-1]=2*(y[j]-y[0]);
      c[j-1]=x[0]*x[0]-x[j]*x[j]+y[0]*y[0]-y[j]*y[j];
    }
    xa=(b[0]*c[1]-b[1]*c[0])/(a[0]*b[1]-a[1]*b[0]);
    ya=(c[0]*a[1]-c[1]*a[0])/(a[0]*b[1]-a[1]*b[0]);
    printf("%.3f %.3f %.3f\n",xa,ya,hypot(abs(xa-x[0]),abs(ya-y[0])));
  }
}

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

int main(){
  int n;
  double a,b,c,d,e,f,x,y,r;
  double x1,y1,x2,y2,x3,y3;

  std::cin >> n;

  for(int i=0;i<n;i++){
    std::cin >> x1>>y1>>x2>>y2>>x3>>y3;
    a = 2*(x1-x2);
    b = 2*(y1-y2);
    c = +(x1*x1-x2*x2)+(y1*y1-y2*y2);
    d = 2*(x2-x3);
    e = 2*(y2-y3);
    f = +(x2*x2-x3*x3)+(y2*y2-y3*y3);

    x = (double)(c*e-b*f)/(a*e-b*d);
    y = (double)(a*f-c*d)/(a*e-b*d);

    if(x == 0){x = 0;}
    if(y == 0){y = 0;}

    r = sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));

    std::printf("%.3f %.3f %.3f\n",x,y,r);
  }
}

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

int main(){
	double x[4],y[4],a[3],b[3],c[3],cx[1000],cy[1000],rx,ry,r[1000];
	int i,n,j;
	
	scanf("%d",&n);
	for(j=0;j<n;j++){
	
	for(i=0;i<3;i++)scanf("%lf%lf",&x[i],&y[i]);
	a[0]=2*(x[1]-x[0]);
	b[0]=2*(y[1]-y[0]);
	c[0]=x[0]*x[0]-x[1]*x[1]+y[0]*y[0]-y[1]*y[1];
	a[1]=2*(x[2]-x[0]);
	b[1]=2*(y[2]-y[0]);
	c[1]=x[0]*x[0]-x[2]*x[2]+y[0]*y[0]-y[2]*y[2];
	
	cx[j]=(b[0]*c[1]-b[1]*c[0])/(a[0]*b[1]-a[1]*b[0]);
	cy[j]=(c[0]*a[1]-c[1]*a[0])/(a[0]*b[1]-a[1]*b[0]);
	
	rx=x[0]-cx[j];
	ry=y[0]-cy[j];
	r[j]=sqrt(rx*rx+ry*ry);
	
	}
	
	for(i=0;i<n;i++)printf("%.3f %.3f %.3f\n",cx[i],cy[i],r[i]);
	
	return 0;
}

C++: #include <iostream>
#include<math.h>
#include<cstdio>
using namespace std;
  
int main(){
    double x1,x2,x3,y1,y2,y3,trgr,trgx,trgy,A1,B1,C1,A2,B2,C2;
    int i,n;
    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;
     
    trgx=(B1*C2-B2*C1)/(A1*B2-A2*B1);
    trgy=(C1*A2-C2*A1)/(A1*B2-A2*B1);
    trgr=sqrt((trgx-x1)*(trgx-x1)+(trgy-y1)*(trgy-y1));
        printf("%.3lf %.3lf %.3lf\n",trgx,trgy,trgr);
    }
    return 0;
}

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

using namespace std;

void calcInverseMatrix(double A[][3], double invA[][3]);

int main(void)
{
	int n = 0;
	cin >> n;
	
	for(int i = 0; i < n; i++){
		double x1 = 0.0, y1 = 0.0;
		double x2 = 0.0, y2 = 0.0;
		double x3 = 0.0, y3 = 0.0;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		
		double A[3][3] = {0};
		double invA[3][3] = {0};
		
		A[0][0] = x1;
		A[0][1] = y1;
		A[0][2] = 1.0;
		A[1][0] = x2;
		A[1][1] = y2;
		A[1][2] = 1.0;
		A[2][0] = x3;
		A[2][1] = y3;
		A[2][2] = 1.0;
		
		calcInverseMatrix(A, invA);
		
		double B[3] = {0};
		B[0] = - x1 * x1 - y1 * y1;
		B[1] = - x2 * x2 - y2 * y2;
		B[2] = - x3 * x3 - y3 * y3;
		
		double C[3] = {0};
		for(int i = 0; i < 3; i++){
			C[i] = invA[i][0]*B[0] + invA[i][1]*B[1] + invA[i][2]*B[2];
		}
		
		double centX = - C[0] / 2.0;
		double centY = - C[1] / 2.0;
		double radius = sqrt(centX * centX + centY * centY - C[2] * C[2]);
		cout << showpoint << setprecision(4) << centX << " " << centY << " " << radius << endl;
	}
	
	return 0;
}

void calcInverseMatrix(double A[][3], double invA[][3])
{
	double det = 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];
	
	invA[0][0] = (A[1][1]*A[2][2] - A[1][2]*A[2][1]) / det;
	invA[0][1] = (A[0][2]*A[2][1] - A[0][1]*A[2][2]) / det;
	invA[0][2] = (A[0][1]*A[1][2] - A[0][2]*A[1][1]) / det;
	invA[1][0] = (A[1][2]*A[2][0] - A[1][0]*A[2][2]) / det;
	invA[1][1] = (A[0][0]*A[2][2] - A[0][2]*A[2][0]) / det;
	invA[1][2] = (A[0][2]*A[1][0] - A[0][0]*A[1][2]) / det;
	invA[2][0] = (A[1][0]*A[2][1] - A[1][1]*A[2][0]) / det;
	invA[2][1] = (A[0][1]*A[2][0] - A[0][0]*A[2][1]) / det;
	invA[2][2] = (A[0][0]*A[1][1] - A[0][1]*A[1][0]) / det;
}

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

int main(void){
    int n;
    long double 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;
}