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<cstdio>
#include<math.h>

struct Zahyou
{
	float x, y;
};
Zahyou de[4];

int main()
{
	int n;

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 1; j < 4; j++)
		{
			scanf("%f %f", &de[j].x, &de[j].y);
		}
		de[0].x = ((de[1].y - de[3].y)*(pow(de[1].y, 2) - pow(de[2].y, 2) + pow(de[1].x, 2) - pow(de[2].x, 2)) + (de[1].y - de[2].y)*(pow(de[1].y, 2) - pow(de[3].y, 2) + pow(de[1].x, 2) - pow(de[3].x, 2))) / (2 * (de[1].y - de[3].y)*(de[1].x - de[2].x) + 2 * (de[1].y - de[2].y)*(de[1].x - de[3].x));
		de[0].y = ((de[1].x - de[3].x)*(pow(de[1].x, 2) - pow(de[2].x, 2) + pow(de[1].y, 2) - pow(de[2].y, 2)) + (de[1].x - de[2].y)*(pow(de[1].x, 2) - pow(de[3].x, 2) + pow(de[1].y, 2) - pow(de[3].y, 2))) / (2 * (de[1].x - de[3].x)*(de[1].y - de[2].y) + 2 * (de[1].x - de[2].x)*(de[1].y - de[3].y));
		
		printf("%.3f %.3f %.3f\n",de[0].x,de[0].y,sqrt(de[0].x+de[0].y));
	}
	return 0;
}

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

using namespace std;

int main()
{
	double x1, y1, x2, y2, x3, y3;
	double px, py, r;
	int n;
	cin >> n;
	
	cout << fixed << setprecision(3);
	
	for (int i=0; i<n; i++) {
		cin >> x1; cin >> y1; cin >> x2; cin >> y2; cin >> x3; cin >> y3;

		double a,b,c,d,e,f;
		a = 2 * (x2 - x1);
		b = 2 * (y2 - y1);
		c = 2 * (x3 - x1);
		d = 2 * (y3 - y1);
		e = x2 * x2 + y2 * y2 - x1 * x1 - y1 * y1;
		f = x3 * x3 + y3 * y3 - x1 * x1 - y1 * y1;
		
		if (a*d==b*c) continue;
		
		double D = a*d - b*c;
		
		px = (d*e  - b*f) / D; px += 0;
		py = (-c*e + a*f) / D; py += 0;
		r  = sqrt((x1-px)*(x1-px) + (y1-py)*(y1-py));
		
		cout << px << " " << py << " " << r << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>
#include <map>
#include <math.h>
#include <utility>


#pragma warning(disable:4996)
using namespace std;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;
const double PI = 3.141592653589793238;
const Int INF = 999999999999;
typedef pair<int, int> P;


double A[2][2];
double C[2];


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

		double x21 = x2 - x1;
		double x31 = x3 - x1;
		double y21 = y2 - y1;
		double y31 = y3 - y1;

		double xc = ((y31*(x21*x21 + y21*y21)) - (y21*(x31*x31 + y31*y31))) /
			(2 * (x21*y31 - y21*x31));

		double yc = ((x21*(x31*x31 + y31*y31)) - (x31*(x21*x21 + y21*y21))) /
			(2 * (x21*y31 - y21*x31));	
		
		double d = (xc - x1)*(xc - x1) + (yc - y1)*(yc - y1);
		int xc_ = xc * 1000;
		int yc_ = yc * 1000;
		xc_ += (xc_ % 10) > 4 ? 10 : 0;
		yc_ += (yc_ % 10) > 4 ? 10 : 0;

		printf("%.3lf %.3lf %.3lf\n", xc, yc, sqrt(d));


	}

}

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.x-b.y),a.x-b.x),
			    (a+c)/2,(a+c)/2+P(-(a.x-c.y),a.x-c.x) );
		printf("%.4f %.4f %.4f\n",g.x,g.y,dist(g,a));
	}
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	while(n){
		double x[3],y[3];
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];

		double  a[2],b[2],c[2];
		for(int i=0;i<2;i++){
			a[i] = 2*(x[i]-x[i+1]);
			b[i] = 2*(y[i]-y[i+1]);
			c[i] = x[i]*x[i]-x[i+1]*x[i+1]+y[i]*y[i]-y[i+1]*y[i+1];
		}
		double ansx,ansy,r;
		ansx = (c[0]*b[1]-c[1]*b[0])/(a[0]*b[1]-a[1]*b[0]);
		ansy = (a[1]*c[0]-a[0]*c[1])/(a[1]*b[0]-a[0]*b[1]);
		r = hypot(x[0]-ansx,y[0]-ansy);
		cout << fixed << setprecision(3) <<  ansx << " " << ansy << " " << r <<  endl;
		n--;
	}
	return 0;
}

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

int main(void){
	int n;
	cin >> n;
	double x1,x2,x3,y1,y2,y3;
	for(int i = 0 ; i < n ; i ++){
		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 x = (2 * (y3 - y1) * a - 2 * (y2 - y1) * b ) / c;
		double y = (2 * (x3 - x1) * a - 2 * (x2 - x1) * b ) / c;
		double r = sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
		
		printf("%.3lf %.3lf %.3lf\n",x,y,r);
		
	} 
	return 0;
}