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

double det(double a, double b, double c, double d, double e, double f, double g, double h, double i){
	double delta;
	double m[3][3] = {{a, b, c},{d, e, f},{g, h, i}};
	delta = m[0][0]*m[1][1]*m[2][2];
	delta += m[2][0]*m[0][1]*m[1][2];
	delta += m[0][2]*m[1][0]*m[2][1];
	delta -= m[0][2]*m[1][1]*m[2][0];
	delta -= m[0][0]*m[1][2]*m[2][1];
	delta -= m[2][2]*m[0][1]*m[1][0];
	return delta;
}

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		double x1, y1, x2, y2, x3, y3, x, y, r;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double d0 = det(x1, y1, 1, x2, y2, 1, x3, y3, 1);
		double d1 = det((-((x1*x1)+(y1*y1))), y1, 1, (-((x2*x2)+(y2*y2))), y2, 1, (-((x3*x3)+(y3*y3))), y3, 1);
		double d2 = det(x1, (-((x1*x1)+(y1*y1))), 1, x2, (-((x2*x2)+(y2*y2))), 1, x3, (-((x3*x3)+(y3*y3))), 1);
		double d3 = det(x1, y1, (-((x1*x1)+(y1*y1))), x2, y2, (-((x2*x2)+(y2*y2))), x3, y3, (-((x3*x3)+(y3*y3))));
		double l, m, n;
		l = d1 / d0;
		m = d2 / d0;
		n = d3 / d0;
		x = -(l / 2);
		y = -(m / 2);
		r = sqrt((l*l + m*m - (4*n)) / 4);
		printf("%.3f %.3f %.3f\n", x, y, r);
	}
	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
int n;
cin>>n;
rep(i,n){
double a,b,c,d,e,f;
cin>>a>>b>>c>>d>>e>>f;
double x,y,r;
double p,q,s,t,u,v,w,z;
p=b-f;
q=e-a;
s=(a+c)/2;
t=(b+f)/2;

u=b-d;
w=(a+c)/2;
v=c-a;
z=(b+d)/2;

x=(v*p*w-u*p*z-u*p*s+u*p*t)/(v*p-u*q);
if(u)y=v*(x-w)/u+z;
else y=q*(x-s)/p+t;
r=hypot(x-a,y-b);

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

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

void OutputCentralCoodinateAndRadius(double x1, double y1, double x2, double y2, double x3, double y3)
{
	double x, y, r;
	if(y1 == y2 || y2 == y3 || y3 == y1){
		if(y2 == y3){
			swap(x3, x1);
			swap(y3, y1);
		}else if(y3 == y1){
			swap(x2, x3);
			swap(y2, y3);
		}
		double xa = (x2 + x3) / 2;
		double ya = (y2 + y3) / 2;
		double a  = (-x3 + x2) / (y3 - y2);
		x = (x1 + x2) / 2;
		y = a * (x - xa) + ya;
	}else{
		double xa = (x1 + x2) / 2;
		double ya = (y1 + y2) / 2;
		double a  = (-x2 + x1) / (y2 - y1);
		double xb = (x2 + x3) / 2;
		double yb = (y2 + y3) / 2;
		double b  = (-x3 + x2) / (y3 - y2);
		x = (b * xb - a * xa - yb + ya) / (b - a);
		y = a * (x - xa) + ya;
	}
	r = sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
	cout << fixed << setprecision(3) << x << ' ' << y << ' ' << r << endl;
}

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;
		OutputCentralCoodinateAndRadius(x1, y1, x2, y2, x3, y3);
	}
	return 0;
}

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

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

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

int main() {
	int n;
	cin>>n;
	for(int h=0;h<n;h++){
double x1,y1,x2,y2,x3,y3,x2m,x3m,y2m,y3m,x21,y21,x31,y31,xy21,xans,yans;
cin>>x1>>y1>>x2>>y2>>x3>>y3;
	x2m=(x1+x2)/2;
	y2m=(y1+y2)/2;
	x3m=(x1+x3)/2;
	y3m=(y1+y3)/2;
	x21=x2-x1;
	x31=x3-x1;
	y21=y2-y1;
	y31=y3-y1;
	
	
if(y1!=y2){
	xy21=x21/y21;
	xans=(x31*x3m-y31*(xy21*x2m+y3m-y2m))/(x31-y31*xy21);
	yans=-xy21*(xans-x2m)+y2m;
}	
else{
	xans=x2m;
	yans=(x3m-xans)*x31/y31+y3m;
}
double r;
r=sqrt((xans-x1)*(xans-x1)+(yans-y1)*(yans-y1));
double x=xans,y=yans;
if(x<0.0004&& x>-0.0004) x=0.000;
if(y<0.0004&& y>-0.0004) y=0.000;

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

	return 0;
}

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

int main(){
    double x1,y1,x2,y2,x3,y3;
    int n;
    cin >> n;
    double a,b,c;
    double ans1,ans2;
    for(int i=0;i<n;i++){
        double ans = 0;
        cin >> x1 >> y1 >> x2 >> y2 >> x2 >> x3 >> y3;
        a = hypot(x2 - x1,y2 - y1);
        b = hypot(x3 - x1,y3 - y1);
        c = hypot(x3 - x2,y3 - y2);
        ans = (a*b*c) / (sqrt((a+b+c)*(b+c-a)*(a-b+c)*(a+b-c)));
        ans1 = (((x1*x1)+(y1*y1))*(y2-y3)+((x2*x2)+(y2*y2))*(y3-y1)+((x3*x3)+(y3*y3))*(y1-y2))/(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2;
        ans2 = (((x1*x1)+(y1*y1))*(x2-x3)+((x2*x2)+(y2*y2))*(x3-x1)+((x3*x3)+(y3*y3))*(x1-x2))/(y1*(x2-x3)+y2*(x3-x1)+y3*(x1-x2))/2;
        printf("%.3f %.3f %.3f\n",ans1,ans2,ans);
    }
}

C++: #include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double a1, b1, c1, a2, b2, c2;
		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;
		double x, y, r;
		x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
		y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
		r = sqrt((x1 - x)*(x1 - x) + (y1 - y)*(y1 - y));
		cout << fixed << std::setprecision(3) << x << " " << y << " " << r << "\n";
	}

	return 0;
}

C++: #include<iostrea>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){

  double x[3], y[3], mx, my, lx, ly, dm, dl, cx, cy, r;
  
  for(int i=0; i<3; i++){
    cin >> x[i] >> y[i];
  }
  
  mx = (x1 + x2) / 2;
  my = (y1 + y2) / 2;
  dm = (y1 - y2) / (x1 - y2);
  lx = (x2 + x3) / 2;
  ly = (y2 + y3) / 2;
  dl = (y2 - y3) / (x2 - x3);
  cx = (my + dm * mx) - (ly + dl * lx);
  cy = (ly + dl * lx) * dm - (my + dm * mx) * dl;
  
  r = sqrt((x1 - cx) * (x1 - cx) + (y1 - cy) * (y1 - cy));

  cx = round(cx * 1000) / 1000;
  cy = round(cy * 1000) / 1000;
  r = round(r * 1000) / 1000;

  printf("%.3d %.3d %.3d\n", cx, cy, r);

  return 0;
}

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

int main() {
	int n;
	cin>>n;
	for(int h=0;h<n;h++){
double x1,y1,x2,y2,x3,y3,x2m,x3m,y2m,y3m,x21,y21,x31,y31,xy21,xans,yans;
cin>>x1>>y1>>x2>>y2>>x3>>y3;
	x2m=(x1+x2)/2;
	y2m=(y1+y2)/2;
	x3m=(x1+x3)/2;
	y3m=(y1+y3)/2;
	x21=x2-x1;
	x31=x3-x1;
	y21=y2-y1;
	y31=y3-y1;
	
	
if(y1!=y2){
	xy21=x21/y21;
	xans=(x31*x3m+y31*xy21*x2m+y3m-y2m)/(x31+y31*xy21);
	yans=xy21*(xans-x2m)+y2m;
}	
else{
	xans=x2m;
	yans=(x3m-xans)*x31/y31+y3m;
}
double r;
r=sqrt((xans-x1)*(xans-x1)+(yans-y1)*(yans-y1));
	printf("%.3f %.3f %.3f\n",xans,yans,r);
}

	return 0;
}