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

/*
  P1(x1, y1) P2(x2, y2) P3(x3, y3) P0(x0, y0)

 <円の中心(x0, y0)>
  2*(x2-x1)*x0 + 2*(y2-y1)*y0 = x2*x2 - x1*x1 + y2*y2 - y1*y1
  2*(x3-x1)*x0 + 2*(y3-y1)*y0 = x3*x3 - x1*x1 + y3*y3 - y1*y1
  x0=((y3-y1)*(x2*x2-x1*x1+y2*y2-y1*y1)+(y1-y2)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*(x2-x1)*(y3-y1)-(y2-y1)*(x3-x1))
  y0=((x1-x3)*(x2*x2-x1*x1+y2*y2-y1*y1)+(x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*(x2-x1)*(y3-y1)-(y2-y1)*(x3-x1))

 <円の半径R>
  R = a/(2*sqrt(q-cosA*cosA)) 
  a = sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) ) // P2-P3
  b = sqrt( (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) ) // P1-P3
  c = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) ) // P1-P2
  cosA = (b*b + c*c - a*a)/(2*b*c)
 */

int main()
{
    double x1, x2, x3, y1, y2, y3; // 3角形の3点
    double x0, y0; // 円の中心
    double R;
    double a, b, c, cosA;
    int n;
    cin >> n;

    for(int i=0; i<n; i++){
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        x0=((y3-y1)*(x2*x2-x1*x1+y2*y2-y1*y1)+(y1-y2)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)));
        y0=((x1-x3)*(x2*x2-x1*x1+y2*y2-y1*y1)+(x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)));
        a = sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) );
        b = sqrt( (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) );
        c = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );
        cosA = (b*b + c*c - a*a)/(2*b*c);
        R = a/(2*sqrt(1-cosA*cosA));

        printf("%.3f %.3f %.3f\n", x0, y0, R);
    }

    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("%.3f %.3f %.3f\n",xy.X,xy.Y,r);
	}


	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);
		double x = (c - b*y) / a;
		printf("%.3lf %.3lf %.3lf\n", x, y, hypot(x1 - x, y1 - y));
	}
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int get() { int r; cin >> r; return r; }
double dis(double p, double q, double r, double s) { return sqrt((p - r) * (p - r) + (q - s) * (q - s)); }
signed main() {
	int n; cin >> n;
	while (n--) {
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double p = ((x3 - x2) * (x3 - x1) + (y3 - y2) * (y3 - y1)) / ((x3 - x2) * (y2 - y1) + (y3 - y2) * (x1 - x2)) / 2;
		double x4 = (x1 + x2) / 2 + p * (y2 - y1);
		double y4 = (y1 + y2) / 2 + p * (x1 - x2);
		double r = dis(x1, y1, x4, y4);
		printf("%.3f %.3f %.3f\n", x4, y4, r);
	}
}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	double x[3], y[3], a, b, c, d, e, f, l , m, n;
	cin >> n;
	while(n--){
????????????????cin>> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];
		
		a = 2 * (x[1] - x[0]);
		b = 2 * (y[1] - y[0]);
		c = ( (x[1]*x[1]) + (y[1]*y[1]) ) -( (x[0]*x[0]) + (y[0]*y[0]) );
		
		d = 2 * (x[2] - x[0]);
		e = 2 * (y[2] - y[0]);
		f = ( (x[2]*x[2]) + (y[2]*y[2]) ) -( (x[0]*x[0]) + (y[0]*y[0]) );
		
		l = (c*e - f*b) / (a*e - d*b);
		m = (c*d - f*a) / (b*d - e*a);
		
		n = sqrt((l - x[0])*(l - x[0]) + (m - y[0])*(m - y[0]));
		
		cout << fixed << setprecision(3) << l << " " << m << " " << n << endl;
	}
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double PI = acos(-1.0), EPS = 1e-10;

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

inline double DIST(double x1, double y1, double x2, double y2) {
	return sqrt(SQ(x1 - x2) + SQ(y1 - y2));
}

int main() {
	int N; cin >> N;
	while(N--) {
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		double A = x1 - x2;
		double B = y1 - y2;
		double C = x1 - x3;
		double D = y1 - y3;
		
		double S = SQ(x1) - SQ(x2) + SQ(y1) - SQ(y2);
		double T = SQ(x1) - SQ(x3) + SQ(y1) - SQ(y3);
		
		double X = (D * S - B * T) / 8;
		double Y = (-1 * C * S + A * T) / 8;
		
		printf("%.3f %.3f %.3f\n", X, Y, DIST(x1, y1, X, Y));
	}
	return 0;
}

C++: #include <stdio.h>
#include <math.h>
 
int main()
{
    int i, n;
    double x1, x2, x3, y1, y2, y3;
    double a, b, c, d, e, f;
    double X1, Y1, r;
     
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%lf %lf %lf %lf %lf %lf",&x1, &y1, &x2, &y2, &x3, &y3);
        a = 2 * (x2 - x1);
        b = 2 * (y2 - y1);
        c = x1*x1 - x2*x2 + y1*y1 - y2*y2;
        d = 2 * (x3 - x1);
        e = 2 * (y3 - y1);
        f = x1*x1 - x3*x3 + y1*y1 - y3*y3;
         
        X1 = (b*f - e*c) / (a*e - d*b);
        Y1 = (c*d - f*a) / (a*d - d*b);
        r  = sqrt((X1-x1)*(X1-x1) + (Y1-y1)*(Y1-y1));
         
        // X1 *= 1000;
        // Y1 *= 1000;
        // r  *= 1000;
         
        // X1 = (int)(X1 > 0.0 ? X1+0.5 : X1-0.5);
        // Y1 = (int)(Y1 > 0.0 ? Y1+0.5 : Y1-0.5);
        // r  = (int)(r  > 0.0 ? r +0.5 : r -0.5);
         
        // X1 = (double)X1/1000;
        // Y1 = (double)Y1/1000;
        // r  = (double)r /1000;
         
        printf("%.3f %.3f %.3f\n", X1, Y1, r);
         
         
    }
     
    return 0;
}