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 <cstdio>
#include <complex.h>
#include <vector>
#define EPS 1e-10
#define EQ(a, b) (abs((a) - (b)))
using namespace std;

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

int main(void) {
    int num; cin >> num;
    
    for(int r = 0; r < num; r++) {
        vector<P> vec;
        for(int c = 0; c < 3; c++) {
            double x, y; cin >> x >> y;
            vec.push_back(P(x, y));
        }
        //中点
        P mid1((vec[0] + vec[1]) / 2.0), mid2((vec[1] + vec[2]) / 2.0);
        //法線ベクトル
        cout << mid1  << " " << mid2 << endl;
        P cross1((vec[0] - vec[1]) * P(0, 1)), cross2((vec[1] - vec[2]) * P(0, 1));
        cout << cross1  << " " << cross2 << endl;
        //交点
        P ans(mid1 + cross1 * cross(cross2, (mid2 - mid1)) / cross(cross2, cross1));
        double half_r = abs(ans - vec[0]);
        printf("%.3f %.3f %.3f\n", ans.real(), ans.imag(), half_r);
    }
    return(0);
}

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

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

typedef complex<double> P;
typedef vector<P> VP;
const double EPF = 1e-5;

#define X real()
#define Y imag()
#define EQ(x,y) (abs(x-y) < EPF)

double dot(P a, P b) {
  return (conj(a)*b).X;
}
double cross(P a, P b) {
  return (conj(a)*b).Y;
}
double distPP(P a, P b) {
  return sqrt(dot(a-b,a-b));
}
P crosspoint(P a, P b, P c, P d) {//ac & bd
  double d1 = cross(d-b,b-a);
  double d2 = cross(d-b,c-a);
  if(EQ(d1,0) & EQ(d2,0)) return a;
  if(EQ(d2,0)) return a;
  return a + (c-a)*d1/d2;
}
P normal_vector(P a) {
  P b(a.Y, a.X);
  return b;
}

int main() {
  int n;
  scanf("%d", &n);
  VP a;
  REP(i, 3) {
    double x,y;
    scanf("%lf %lf", &x, &y);
    a.push_back(P(x,y));
  }
  P M = (a[0]+a[1])/(P)2;
  P N = (a[1]+a[2])/(P)2;
  P M_v = normal_vector(a[0]-a[1]);
  P N_v = normal_vector(a[1]-a[2]);  
  P o = crosspoint(M, N, M+M_v, N+N_v);
  printf("%.3lf %.3lf %.3lf\n", o.X, o.Y, distPP(o,a[0]));
  
  return 0;
}

C++: #include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

double a[6];

void solve(){
	double x,y;
	double c[2];
	c[0]=(a[0]+a[2])/2.0;
	c[1]=(a[1]+a[3])/2.0;
	
	double l1[2], k1[2];
	k1[0]=-(a[3]-a[1]);
	k1[1]=(a[2]-a[0]);
	
	double d[2];
	d[0]=(a[4]+a[2])/2.0;
	d[1]=(a[5]+a[3])/2.0;
	
	double l2[2], k2[2];
	k2[0]=-(a[3]-a[5]);
	k2[1]=(a[2]-a[4]);
	
	if(k1[0]==0){
		x=c[0];
		l2[0]=k2[1]/k2[0];
		l2[1]=-l2[0]*d[0]+d[1];
		y=l2[0]*x+l2[1];
		
	}
	else if(k2[0]==0){
		x=d[0];
		l1[0]=k1[1]/k1[0];
		l1[1]=-l1[0]*c[0]+c[1];
		y=l1[0]*x+l1[1];
	}
	else{
		l1[0]=k1[1]/k1[0];
		l1[1]=-l1[0]*c[0]+c[1];
		
		l2[0]=k2[1]/k2[0];
		l2[1]=-l2[0]*d[0]+d[1];
		
		x=-(l2[1]-l1[1])/(l2[0]-l1[0]);
		y=l1[0]*x+l1[1];
	}
	double r=sqrt((x-a[0])*(x-a[0])+(y-a[1])*(y-a[1]));
	
	printf("%.3f %.3f %.3f\n",x,y,r);
}

int main(){
	li n;
	cin>>n;
	
	rin{
		rep(j,6)cin>>a[j];
		solve();
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair

using namespace std;

inline double Square(double x){
	return x*x;
}

struct Pos{
	double x,y;
};

pair<Pos,double> ComputeCircle(Pos p,Pos q,Pos r){
	double a=-2.0*(p.x-q.x);
	double b=-2.0*(p.y-q.y);
	double c=Square(p.x)+Square(p.y)-Square(q.x)-Square(q.y);
	double d=-2.0*(p.x-r.x);
	double e=-2.0*(p.y-r.y);
	double f=Square(p.x)+Square(p.y)-Square(r.x)-Square(r.y);
	double k=1.0/(b*d-a*e);
	double x=(c*e-f*b)*k;
	double y=-(c*d-f*a)*k;
	double rad=sqrt(Square(p.x-x)+Square(p.y-y));
	return MP(Pos{x,y},rad);
}

int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		Pos a,b,c;
		scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y);
		auto p=ComputeCircle(a,b,c);
		printf("%.3f %.3f %.3f\n",p.first.x,p.first.y,p.second);
	}
}

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

using namespace std;

int main()
{
	int n;
	double x1, y1, x2, y2, x3, y3;
	double xp, yp, r;
	double a1, b1, c1, a2, b2 ,c2;
	cin>>n;
	for(int 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;
		xp=(b1*c2-b2*c1)/(a1*b2-a2*b1);
		yp=(c1*a2-c2*a1)/(a1*b2-a2*b1);
		r=fabs(sqrt((x1+xp)*(x1+xp)+(y1+yp)*(y1+yp)));
		printf("%.3lf %.3lf %.3lf\n", xp, yp, r);
	}
}

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 c1 = (x1 + x2) / 2;
		double c2 = (x1 + x3) / 2;
		double d1 = (y1 + y2) / 2;
		double d2 = (y1 + y3) / 2;
		double k1, k2, px, py, r;
		if (x1 != x2 && x1 != x3){
			k1 = (y2 - y1) / (x2 - x1);
			k2 = (y3 - y1) / (x3 - x1);
			py = (c2 - c1 + k2 * d2 - k1 * d1) / (k2 - k1);
			px = k1 * (d1 - py) + c1;
		}
		else{
			if (x1 == x2){
				py = d1;
				px = c2;
			}
			else if (x1 == x3){
				py = d2;
				px = c1;
			}
		}
		r = sqrt((px - x1)*(px - x1) + (py - y1)*(py - y1));

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

C++: #include <iostream>
#include <cmath>
#include <iomanip>
#define sqr(n) ((n) * (n))
using namespace std;

void equation(double a, double b, double c, double d, double e, double f, double *x, double *y)
{
  *x = (c * e - b * f) / (a * e - b * d);
  *y = (a * f - c * d) / (a * e - b * d);   
}

int main()
{
  int n;
  double x1, y1, x2, y2, x3, y3, x, y;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    x = y = 0;
    equation((2 * (x2 - x1)), (2 * (y2 - y1)), (sqr(x2) + sqr(y2) - sqr(x1) - sqr(y1)), (2 * (x3 - x2)), (2 * (y3 - y2)), (sqr(x3) + sqr(y3) - sqr(x2) - sqr(y2)), &x, &y);
    cout << fixed << setprecision(3) << x + 0.0001 << ' ' <<  y + 0.0001 << ' ' << sqrt(sqr(x1 - x) + sqr(y1 - y)) + 0.0001 << endl;
  }
}