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 <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <set>
#include <cmath>

// x^2+y^2+ax+by+c=0

int main(int,char**){
	std::cout<< std::setprecision(3) << std::setiosflags(std::ios::fixed);
	int n;
	std::cin >> n;
	while(n--){
		double x1,y1,x2,y2,x3,y3,a,b,c;
		std::cin >>  x1 >> y1 >> x2 >> y2 >> x3 >>y3;
		double vec[]={ -x1*x1-y1*y1, -x2*x2-y2*y2, -x3*x3-y3*y3};
		double det(x1*y1+x2*y3+x3*y1-x1*y3-x2*y1-x3*y2);
		double inv[3][3] = { 
			{ y2-y3, -(y1-y3), y1-y2 },
			{ -(x2-x3), x1-x3, -(x1-x2) },
			{ x2*y3-x3*y2, -(x1*y3-x3*y1), x1*y2-x2*y1}
		};
		a= (inv[0][0]*vec[0] +inv[0][1]*vec[1] +inv[0][2]*vec[2])/det;
		b= (inv[1][0]*vec[0] +inv[1][1]*vec[1] +inv[1][2]*vec[2])/det;
		c= (inv[2][0]*vec[0] +inv[2][1]*vec[1] +inv[2][2]*vec[2])/det;
		std::cout<< 0-a/2 << ' ' << 0-b/2<<' ' << std::sqrt((a*a+b*b)/4-c)<<std::endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	double x1,y1,x2,y2,x3,y3,xp,yp,r;
	double a,b,c,d,e,f,L,M,N;
	
	cin>>n;
	for (int i=0; i<n; i++) {
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		
		a=x1-x2;
		b=y1-y2;
		c=-1*(x1*x1+y1*y1)+(x2*x2+y2*y2);
		d=x1-x3;
		e=y1-y3;
		f=-1*(x1*x1+y1*y1)+(x3*x3+y3*y3);
		
		if (a==0) {
			M=c/b;
			L=(f-e*M)/d;
		}
		else{
		M=(c*d-a*f)/(b*d-a*e);//
		L=(c-b*M)/a;
		}
		N=-L*x1-M*y1-x1*x1-y1*y1;
		
		xp=-1*(L/2);
		yp=-1*(M/2);
		r=sqrt(-1*N+(L*L)/4+(M*M)/4);
			
		printf("%.3f %.3f %.3f\n",xp,yp,r);
	}
	
	return 0;	
}

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

using namespace std;

int main(){

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

        double p = ((y1 - y3)*(pow(y1, 2) - pow(y2, 2) + pow(x1, 2) - pow(x2, 2)) - (y1 - y2)*(pow(y1, 2) - pow(y3, 2) + pow(x1, 2) - pow(x3, 2))) / (2 * (y1 - y3)*(x1 - x2) - 2 * (y1 - y2)*(x1 - x3));
        double q = ((x1 - x3)*(pow(x1, 2) - pow(x2, 2) + pow(y1, 2) - pow(y2, 2)) - (x1 - x2)*(pow(x1, 2) - pow(x3, 2) + pow(y1, 2) - pow(y3, 2))) / (2 * (x1 - x3)*(y1 - y2) - 2 * (x1 - x2)*(y1 - y3));
        double r = pow((pow((x1 - p), 2) + pow((y1 - q), 2)), 0.5);

        printf("%.3f %.3f %.3f\n", p, q, r);
    }

    return 0;
}

C++: #include<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<cmath>
#include<vector>
#include<map>
using namespace std;


#define INF 1e+10
#define EPS 1e-10
#define EQ(a,b) (abs(a-b)<EPS)

//誤差を考慮して足し算
double add(double a,double b){
	if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
	return a+b;
}
struct P{//2次元ベクトル
	double x,y;
	P(){}
	P(double x,double y):x(x),y(y){}
	P operator + (P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator - (P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator * (double d){
		return P(x*d,y*d);
	}
	P operator / (double d){
		return P(x/d,y/d);
	}
	double dot(P p){//内積
		return add(x*p.x,y*p.y);
	}
	double det(P p){//外積
		return add(x*p.y,-y*p.x);
	}
	bool equal(P p){
		return (x-p.x)*(x-p.x)+(y-p.y)*(y-p.y) < EPS*EPS;
	}
};
//typedef pair<P,P> Line;

//線分p1-p2上に点qがあるか判定
bool on_seg(P p1,P p2,P q){
	return (p1-q).det(p2-q)==0 && (p1-q).dot(p2-q)<=0;
}
//直線p1-p2と直線q1-q2の交点
P intersection(P p1,P p2,P q1,P q2){
	return p1+(p2-p1)*( (q2-q1).det(q1-p1)/(q2-q1).det(p2-p1) );
}


//線分p1-p2と線分q1-q2が交差するか
bool intersecting(P p1,P p2,P q1,P q2){
	if(on_seg(p1,p2,q1)||on_seg(p1,p2,q2)||on_seg(q1,q2,p1)||on_seg(q1,q2,p2))return true;
	if((p1-p2).det(q1-q2)==0 )return false;//平行
	P a=intersection(p1,p2,q1,q2);
	return on_seg(p1,p2,a) && on_seg(q1,q2,a);
}
//原点中心回転
P rotate(P p,double rad){
	double s=sin(rad),c=cos(rad);
	return P(c*p.x-s*p.y, s*p.x+c*p.y);
}
//originを中心回転
P rotate(P p,double rad,P origin){
	return origin + rotate(p - origin,rad);
}
//二点間の距離
double dist(P p,P q){
	p = p-q;
	return sqrt(p.x*p.x+p.y*p.y);
}
//単位ベクトルに変換
P to_unit(P p){
	double d = sqrt(p.x*p.x+p.y*p.y);
	return p/d;
}
//円同士の交点を計算
pair<P,P> circle_intersection(double x1,double y1,double r1,double x2,double y2,double r2){
	double rad = atan2(y2-y1,x2-x1);
	x2 -= x1;
	y2 -= y1;
	P tmp = rotate(P(x2,y2),-rad);
	x2 = tmp.x;
	y2 = tmp.y;
	double x = (r1*r1-r2*r2+x2*x2)/(2*x2);
	if(abs(r1) < abs(x))return make_pair(P(0,0),P(0,0));//交点なし
	double y = sqrt(r1*r1-x*x);
	return make_pair( P(x1,y1)+rotate(P(x,y),rad) ,  P(x1,y1)+rotate(P(x,-y),rad) );
}
//線分と点の距離
double dist_lp(P p1,P p2,P q){
	double dx,dy;
	dx = p1.x-p2.x;
	dy = p1.y-p2.y;
	double d = min(dist(p1,q) ,dist(p2,q));
	pair<P,P> normal= make_pair(q+to_unit(P(-dy,dx))*d ,q+to_unit(P(dy,-dx))*d);//法線ベクトル
	if(intersecting(p1,p2,normal.first,normal.second)){
		return dist(q, intersection(p1,p2,normal.first,normal.second));
	}
	return d;
}
//線分同士の距離
double dist_ll(P p1,P p2,P q1,P q2){
	if(intersecting(p1,p2,q1,q2))return 0;
	return min( min(dist_lp(p1,p2,q1),dist_lp(p1,p2,q2))
		,min(dist_lp(q1,q2,p1),dist_lp(q1,q2,p2)) );
}
//ラジアンに変換
double radian(double angle){
	return angle/180.0*M_PI;
}


int main(){
	P a,b,c,g;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a.x>>a.y;
		cin>>b.x>>b.y;
		cin>>c.x>>c.y;
		g = intersection((a+b)/2,(a+b)/2+P(-(a.y-b.y),a.x-b.x),
			    (a+c)/2,(a+c)/2+P(-(a.y-c.y),a.x-c.x) );
		printf("%.3f %.3f %.3f\n",g.x,g.y,dist(g,a));
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

double distance(double x0, double y0, double x1, double y1)
{
	double x = x1 - x0;
	double y = y1 - y0;

	return sqrt(x * x + y * y);
}

int main()
{
	int n;
	for (cin >> n; n--;)
	{
		vector<double> x(3);
		vector<double> y(3);

		for (int i = 0; i < 3; i++)
		{
			cin >> x.at(i) >> y.at(i);
		}

		double a = distance(x.at(1), y.at(1), x.at(2), y.at(2));
		double b = distance(x.at(2), y.at(2), x.at(0), y.at(0));
		double c = distance(x.at(0), y.at(0), x.at(1), y.at(1));

		double cosA = (b * b + c * c - a * a) / (2 * b * c);
		double sinA = sqrt(1 - cosA * cosA);
		double r = a / (2 * sinA);

		double px = r * sinA;
		double py = r * cosA;

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

C++: #include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int a;
    scanf("%d",&a);
    for(;;a--){
        double a1,a2,b1,b2,c1,c2,x1,y1,x2,y2,x3,y3;
        double x,y,r;
        scanf("%lf%lf%lf%lf%lf%lf",&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;
        x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
        y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
        r=hypot(x-x1,y-y1);
        printf("%.3lf %.3lf %.3lf\n",x,y,r);
    }
    return 0;
}