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

double marume( double x ){
	long long t = x * 1000 + 0.5;
	return t/1000.0;
}

int main(){
	int n;
	double tx, ty, x1, y1, x2, y2;
	
	cin >> n;
	while(n--){
		cin >> tx >> ty >> x1 >> y1 >> x2 >> y2;
		x1 -= tx; y1 -= ty;
		x2 -= tx; y2 -= ty;
		
		double dist1 = x1 * x1 + y1 * y1;
		double dist2 = x2 * x2 + y2 * y2;
		x1 *= 2; y1 *= 2;
		y1 *= 2; y2 *= 2;
		
		double detA = x1 * y2 - x2 * y1;
		double detX = dist1 * y2 - y1 * dist2;
		double detY = x1 * dist2 - dist1 * x1;
		double x = detX / detA;
		double y = detY / detA;
		double r = hypot(x, y);
		
		x += tx;
		y += ty;
		
		x = marume(x);
		y = marume(y);
		r = marume(r);
		printf("%.3f %.3f %.3f\n", x, y, r);
	}
	return 0;
}

C++: #include <iostream>
#include <complex>
#include <cmath>
#define X real()
#define Y imag()
#define F first
#define S second
#define ML make_pair
#define EPS 1e-10
#define PI acos(-1)
using namespace std;
typedef long double  D;
typedef complex<double> P;
typedef complex<double> V;
typedef pair<P,P> L;


// 内積 (Inner Product) : a・b = |a||b|cosθ 1
D IP(V a, V b) {
	return (a.real() * b.real() + a.imag() * b.imag());
}

// 外積 (Exterior Product) : |a×b| = |a||b|sinθ 2
D EP(V a, V b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}

//交点判定
bool ISC(L l1,L l2){
	V v1,v2;
	v1=l1.S-l1.F;
	v2=l2.S-l2.F;
	if(abs(EP(v1,v2))<EPS)
		return false;
	else
		return true;
}

//　交点の座標
P IS(L l1,L l2){
	P p1,p2,p3,p4;
	p1=l1.F,p2=l1.S,p3=l2.F,p4=l2.S;
	D tmp=(EP(p4-p3,p3-p1)/EP(p4-p3,p2-p1));
	V v1=(tmp,tmp);
	return p1+(p2-p1)*v1;
}
int main(void){
	int n;
	cin >>n;
	for(int j=0;j<n;j++){
		P point[4],tmp1,tmp2;
		for(int i=0;i<3;i++)
			cin >> point[i].X >> point[i].Y;
		L l1,l2;
		tmp1=((point[0]+point[1])/P(2.0,0));
		D angle,r=1.0;
		angle=arg(point[1]-point[0]);
		angle+=PI/2.0;
		tmp2=polar(r,angle);
		l1=ML(tmp1,tmp1+tmp2);

		tmp1=(point[0]+point[2])/P(2.0,0);
		angle=arg(point[2]-point[0]);
		angle+=PI/2.0;
		tmp2=polar(r,angle);
		l2=ML(tmp1,tmp1+tmp2);

		point[3]=IS(l1,l2);
		cout << point[3].X << ' '<< point[3].Y << ' '<< abs(point[3]-point[0]) << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	
	for (int i  = 0; i < n; i++){
		double x[3], y[3], s[3];
		double l, m, n;
		
		for (int j = 0; j < 3; j++){
			scanf("%lf %lf", &x[j], &y[j]);
			s[j] = x[j] * x[j] + y[j] * y[j];
		}
		
		double x2[2], y2[2], s2[2];
		x2[0] = x[0] - x[1];
		y2[0] = y[0] - y[1];
		s2[0] = s[0] - s[1];
		x2[1] = x[0] - x[2];
		y2[1] = y[0] - y[2];
		s2[1] = s[0] - s[2];
		
		m = - (s2[0] * x2[1] - s2[1] * x2[0]) / (y2[0] * x2[1] - y2[1] * x2[0]);
		l = - (s2[0] * y2[1] - s2[1] * y2[0]) / (x2[0] * y2[1] - x2[1] * y2[0]);
		n = - s[0] - x[0] * l - y[0] * m;
		
		double a,b,r;
		
		a = l / -2;
		b = m / -2;
		r = sqrt(- n - a * a - b * b - l * a - m * b);
		
		printf("%.3lf %.3lf %.3lf\n", a, b, r);
		
		}
	return(0);
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

using namespace std;

int main(){

	int n;


	cin >> n;

	double x1,y1,x2,y2,x3,y3;
	rep(i,n){

	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

	double a=x2*x2-x1*x1+y2*y2-y1*y1;
	double b=x3*x3-x1*x1+y3*y3-y1*y1;
	double c=4*(x2-x1)*(y3-y1)-4*(x3-x1)*(y2-y1);

	double xp=(2*(y3-y1)*a-2*(y2-y1)*b)/c;
	double yp=(-2*(x3-x1)*a+2*(x2-x1)*b)/c;
	double r=sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));

    printf("%.3lf %.3lf %.3lf\n",xp,yp,r);

	}


	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

double sq(double x){ return x * x; }
double sqs(double x, double y){ return sq(x) + sq(y); }

// ax + by = c
// dx + ey = f
void F(double *x, double *y, double a, double b, double c, double d, double e, double f)
{
  *y = (c * d - f * a) / (d * b - e * a);
  *x = (c - b * *y) / a;
}

int main()
{
  int n = in();
  while (n--){
    double x0, y0, x1, y1, x2, y2;
    cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2;
    // (x - a)^2 + (y - b)^2 = r^2
    // x^2 + y^2 + lx + my + n = 0
    // -a = l / 2
    // -b = m / 2
    double l, m;
    F(&l, &m, x0 - x1, y0 - y1, sqs(x1, y1) - sqs(x0, y0), x0 - x2, y0 - y2, sqs(x2, y2) - sqs(x0, y0));
    double px = -l / 2, py = -m / 2;
    double r = sqrt(sq(x0 - px) + sq(y0 - py));
    printf("%.3lf %.3lf %.3lf\n", px, py, r);
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>

using namespace std;

int main(){

	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		complex<double> A,B,C;
		cin >> A.real() >> A.imag() >> B.real() >> B.imag() >> C.real() >> C.imag();
		double b = abs(A-C);
		double a = abs(B-C);
		double c = abs(A-B);
		double s = (a+b+c)/2;
		double S = sqrt(s*(s-a)*(s-b)*(s-c));
		double R = a*b*c/(4*S);
		complex<double> cent;

		cent.real() = (a*a*(b*b+c*c-a*a)*A.real() + b*b*(a*a+c*c-b*b)*B.real() + c*c*(b*b+a*a-c*c)*C.real())/(16*S*S);
		cent.imag() = (a*a*(b*b+c*c-a*a)*A.imag() + b*b*(a*a+c*c-b*b)*B.imag() + c*c*(b*b+a*a-c*c)*C.imag())/(16*S*S);

		printf("%.3f %.3f %.3f\n",cent.real(),cent.imag(),R);
		//cout << cent.real() << " " << cent.imag() << " " << R << endl;
		//double cosA = (b*b+c*c-a*a)/(2*b*c);
		//double sinA = sqrt(1-cosA*cosA);
		//double R = a/(2*sinA);

	}

	return 0;
}