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<math.h>
#include<iomanip>

using namespace std;

int main(){
	int n;
	double x1,y1,x2,y2,x3,y3,px,py,r;
	cin>>n;
	cout<<setprecision(3);
	cout<<fixed;
	while(n--){
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		px=-1.0/2*((x2*x2-x1*x1)*(y3-y1)-(x3*x3-x1*x1)*(y2-y1)+(y3-y1)*(y2-y1)*(y2-y3))/((x3-x1)*(y2-y1)-(x2-x1)*(y3-y1));
		if(y2-y1 != 0){
			py=-(x2-x1)/(y2-y1)*(px-(x1+x2)/2)+(y1+y2)/2;
		}else{
			py=-(x3-x1)/(y3-y1)*(px-(x1+x3)/2)+(y1+y3)/2;
		}
		r=sqrt((px-x1)*(px-x1)+(py-y1)*(py-y1));
		cout<<px<<' '<<py<<' '<<r<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<math.h>
using namespace std;
int main() {
	float x1, x2, x3, px, y1, y2, y3, py,r;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		if (y1 == y2) {
			px = (x1 + x2) / 2;
			py = (x1 - x3)*(x2 - x3) / (2 * (y3 - y1)) + (y1 + y3) / 2;
		}
		else if (y1 == y3) {
			px = (x1 + x3) / 2;
			py = (x1 - x2)*(x3 - x2) / (2 * (y2 - y1)) + (y1 + y2) / 2;
		}
		else {
			px = ((x1*x1 - x2*x2) / (y2 - y1) - (x1*x1 - x3*x3) / (y3 - y1) + y3 - y2) / (2 * ((x1 - x2) / (y2 - y1) - (x1 - x3) / (y3 - y1)));
			py = (px - (x1 + x2) / 2)*(x1 - x2) / (y2 - y1) + (y1 + y2) / 2;
		}
		r = sqrt((px - x1)*(px - x1) + (py - y1)*(py - y1));
		px = float(int(1000 * px + 0.5)) / 1000;
		py = float(int(1000 * py + 0.5)) / 1000;
		r = float(int(1000 * r + 0.5)) / 1000;
		cout << px << " " << py << " " << r << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double a = -x1 + x2, b = -y1 + y2, c = (-pow(x1, 2) - pow(y1, 2) + pow(x2, 2) + pow(y2, 2)) / 2;
		double d = -x1 + x3, e = -y1 + y3, f = (-pow(x1, 2) - pow(y1, 2) + pow(x3, 2) + pow(y3, 2)) / 2;
		double y = (c*d - a*f) / (b*d - a*e);
		string t = to_string(y);
		if (t == "-nan(ind)")abort();
		double x = (c - b*y) / a;
		string s = to_string(x);
		if (s == "-nan(ind)")abort();
		printf("%.3lf %.3lf %.3lf\n", x, y, hypot(x1 - x, y1 - y));
	}
}

C++: #include <stdio.h>
#include <math.h>
int main(){
    double x[4],y[4];
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int i=0;i<3;i++)scanf("%lf%lf",&x[i],&y[i]);
        x[3]=y[0]*(x[2]*x[2]+y[2]*y[2])+y[1]*(x[0]*x[0]+y[0]*y[0])+y[2]*(x[1]*x[1]+y[1]*y[1])-y[0]*(x[1]*x[1]+y[1]*y[1])-y[1]*(x[2]*x[2]+y[2]*y[2])-y[2]*(x[0]*x[0]+y[0]*y[0]);
        y[3]=x[0]*(x[2]*x[2]+y[2]*y[2])+x[1]*(x[0]*x[0]+y[0]*y[0])+x[2]*(x[1]*x[1]+y[1]*y[1])-x[0]*(x[1]*x[1]+y[1]*y[1])-x[1]*(x[2]*x[2]+y[2]*y[2])-x[2]*(x[0]*x[0]+y[0]*y[0]);
        y[3]=-y[3];
        x[3]/=x[0]*y[1]+x[1]*y[2]+x[2]*y[0]-x[0]*y[2]-x[1]*y[0]-x[2]*y[1];
        y[3]/=x[0]*y[1]+x[1]*y[2]+x[2]*y[0]-x[0]*y[2]-x[1]*y[0]-x[2]*y[1];
        y[3]/=2;
        x[3]/=2;
        printf("%.3f %.3f %.3f\n",x[3]-0.0005,y[3]-0.0005,sqrt((x[3]-x[0])*(x[3]-x[0])+(y[3]-y[0])*(y[3]-y[0]))-0.0005);
    }
}

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

using namespace std;

int main(){

	double x[3+1],y[3+1];
	double xp,yp;
	double a[2+1],b[2+1],c[2+1];
	double r;
	for(int i=1;i<4;i++){
		cin>>x[i];
		cin>>y[i];
	}

	a[1]=2*(x[2]-x[1]);
	b[1]=2*(y[2]-y[1]);
	c[1]=x[1]*x[1]-x[2]*x[2]+y[1]*y[1]-y[2]*y[2];
	a[2]=2*(x[3]-x[1]);
	b[2]=2*(y[3]-y[1]);
	c[2]=x[1]*x[1]-x[3]*x[3]+y[1]*y[1]-y[3]*y[3];

	xp=(b[1]*c[2]-b[2]*c[1])/(a[1]*b[2]-a[2]*b[1]);
	yp=(c[1]*a[2]-c[2]*a[1])/(a[1]*b[2]-a[2]*b[1]);

	r=sqrt( (xp-x[1]*xp-x[1])+(yp-y[1])*(yp-y[1])  );

	printf("%.3f %.3f %.3f",xp,yp,r);

	return 0;

}

C++: #include<iostream>
#include<iomanip>
#include<cmath>
#define PI 3.1415
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 )));


		if( a >= PI ) a=2*PI-a;
		if( b >= PI ) b=2*PI-b;
		if( c >= PI ) c=2*PI-c;


		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<cstdio>
#include<cmath>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    double p[3][2];
    for(int i=0; i<3; i++)
      for(int j=0; j<2; j++)
	cin >>p[i][j];
    for(int i=1; i<3; i++)
      for(int j=0; j<2; j++)
	p[i][j]-=p[0][j];
    double m[2][2],det,im[2][2],x[2],s[2];
    for(int i=0; i<2; i++)
      for(int j=0; j<2; j++)
	m[i][j] = 2*p[i+1][j];
    for(int  i=0; i<2; i++)
      x[i] = p[i+1][0]*p[i+1][0]+p[i+1][1]*p[i+1][1];
    det = m[0][0]*m[1][1]-m[0][1]*m[1][0];
    im[0][0] = m[1][1]/det;
    im[0][1] = -m[0][1]/det;
    im[1][0] = -m[1][0]/det;
    im[1][1] = m[0][0]/det;
    for(int i=0; i<2; i++)
      s[i] = im[i][0]*x[0]+im[i][1]*x[1];
    printf("%.3lf %.3lf %.3lf\n",s[0]+p[0][0],s[1]+p[0][1],sqrt(s[0]*s[0]+s[1]*s[1]));
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <complex>
#include <cstdio>

using namespace std;

typedef complex<double> P;

//ヤバそう？
#define X real()
#define Y imag()


class Triangle{
public:
	P p1,p2,p3;

	//e1:p2-p3間の辺
	double e1,e2,e3;

	//a1:e1の向かいの角
	double a1,a2,a3;

	//cosine formula
	//長さaの辺の向かいの角の角度
	double cf(double a,double b,double c){
		return acos((b*b+c*c-a*a)/(2.0*b*c));
	}

	Triangle(P _p1,P _p2,P _p3){
		p1=_p1;
		p2=_p2;
		p3=_p3;

		e1=abs(p2-p3);
		e2=abs(p1-p3);
		e3=abs(p1-p2);

		a1=cf(e1,e2,e3);
		a2=cf(e2,e1,e3);
		a3=cf(e3,e1,e2);

	}

	P get_center(){
		return (sin(2*a1)*p1+sin(2*a2)*p2+sin(2*a3)*p3)/(sin(2*a1)+sin(2*a2)+sin(2*a3));
	}

	double get_r(){
		return e1/(2.0*sin(a1));
	}


};

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

	for(int i=0;i<n;i++){
		P p[3];
		for(int j=0;j<3;j++){
			double x,y;
			cin>>x>>y;
			p[j]=P(x,y);
		}
		Triangle T(p[0],p[1],p[2]);

		P xy=T.get_center();
		double r=T.get_r();

		printf("%.4f %.4f %.4f\n",xy.X,xy.Y,r);
	}


	return 0;
}