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

int list[1000000] = {};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	
	while(n-- > 0){
	
	double x1, y1, x2, y2, x3, y3;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
	
	double a = 2 * (x2 - x1);
	double b = 2 * (y2 - y1);
	double c = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
	double d = 2 * (x3 - x2);
	double e = 2 * (y3 - y2);
	double f = x2 * x2 - x3 * x3 + y2 * y2 - y3 * y3;
		
	double cx = (b * f - c * e)/(a * e - d * b);
	double cy = (a * f - c * d)/(b * d - a * e);
		
	double r = sqrt((x1 - cx)*(x1 - cx) + (y1 - cy)*(y1 - cy));
	
	cout << fixed << cx << " " << cy << " " << r << endl;
	
	}
	
	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
	double a[2],b[2],c[2];
	double matrix[2][2],ans[2],reverse[2][2],det;
	double r,o[2];
	int n;
	cin >>n;
	for(int i=0; i<n; i++){
		cin >>a[0]>>a[1]>>b[0]>>b[1]>>c[0]>>c[1];
		b[0] = b[0]-a[0];
		b[1] = b[1]-a[1];
		c[0] = c[0]-a[0];
		c[1] = c[1]-a[1];
		matrix[0][0] = 2*b[0];
		matrix[1][0] = 2*b[1];
		matrix[0][1] = 2*c[0];
		matrix[1][1] = 2*c[1];
		ans[0] = b[0]*b[0]+b[1]*b[1];
		ans[1] = c[0]*c[0]+c[1]*c[1];
		det = matrix[0][0]*matrix[1][1]-matrix[0][1]*matrix[1][0];
		reverse[0][0] = matrix[1][1]/det;
		reverse[1][0] = -matrix[1][0]/det;
		reverse[0][1] = -matrix[0][1]/det;
		reverse[1][1] = matrix[0][0]/det;
		o[0] = ans[0]*reverse[0][0]+ans[1]*reverse[1][0];
		o[1] = ans[0]*reverse[0][1]+ans[1]*reverse[1][1];
		r = sqrt(o[0]*o[0]+o[1]*o[1]);
		o[0]+=a[0];
		o[1]+=a[1];
		printf("%.3lf %.3lf %.3lf",o[0],o[1],r);
	}
	return 0;
}

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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

double sqdist( double x1, double y1, double x2, double y2 )
{
	return pow( x1 - x2, 2 ) + pow( y1 - y2, 2 );
}

double dist( double x1, double y1, double x2, double y2 )
{
	return sqrt( sqdist( x1, y1, x2, y2 ) );
}

int main()
{
	int n;
	cin >> n;

	REP( dn, 0, n )
	{
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		double mx = ( x1 + x2 ) / 2, my = ( y1 + y2 ) / 2;
		double a = -( ( x2 - x1 ) / ( y2 - y1 ) );
		double th = atan( a );

		double low = -100.0, high = 100.0, mid = 0;

		REP( i, 0, 1000 )
		{
			mid = ( low + high ) / 2;
			double cx = mx + cos( th ) * mid, cy = my + sin( th ) * mid;

			double d1 = sqdist( x1, y2, cx, cy ), d2 = sqdist( cx, cy, x3, y3 );

			if ( d1 < d2 )
			{
				high = mid;
			}
			else if ( d2 < d1 )
			{
				low = mid;
			}
		}

		double rx = mx + cos( th ) * mid, ry = my + sin( th ) * mid;

		cout.precision( 4 );
		cout << setiosflags( ios::showpoint ) << rx << ' ' << ry << ' ' << dist( x1, x2, rx, ry ) << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <complex>
#include <vector>
#include <algorithm>
using namespace std;

const double EPS = 1e-7;
typedef complex<double> P; /* _ */
struct L {                 /* üª */
	P p, q;
	L(P p, P q) : p(p), q(q) {}
};

// OÏ
double cross(P a, P b) { return imag(conj(a)*b); }

// ¼üaÆ¼übÌð_ðvZ·éDæÉð·»èªK{D
P crossPointLL(L a, L b){
	double A = cross(a.q-a.p, b.q-b.p);
	double B = cross(a.q-a.p, a.q-b.p);
	return b.p + B/A * (b.q-b.p);
}

// _pÆ_qÌ¼ñªüðÔ·
L pointBisector(P p, P q) {
	P cen = (p+q)*0.5;
	return L(cen, cen+(q-p)*P(0,1));
}

int main(){
	int n;
	cin>>n;
	double x1, y1, x2, y2, x3, y3;
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3){
		// Cuè@
		P p1 = P(x1, y1);
		P p2 = P(x2, y2);
		P p3 = P(x3, y3);
		L l1 = pointBisector(p1, p2);
		L l2 = pointBisector(p2, p3);
		P cen = crossPointLL(l1, l2);
		double r = abs(p1-cen);

		// ö®ðp¢½è@
		double a1 = 2*(x2-x1);
		double b1 = 2*(y2-y1);
		double c1 = x1*x1-x2*x2+y1*y1-y2*y2;
		double a2 = 2*(x3-x1);
		double b2 = 2*(y3-y1);
		double c2 = x1*x1-x3*x3+y1*y1-y3*y3;
		double cx = (b1*c2-b2*c1)/(a1*b2-a2*b1);
		double cy = (c1*a2-c2*a1)/(a1*b2-a2*b1);
		P cen2 = P(cx, cy);
		double r2 = abs(p1-cen2);

		printf("%.3f %.3f %.3f", cen.real(), cen.imag(), r);
		cout<<endl;

		// ÜÆß
		//int x1000 = cen2.real() >= 0 ? 1000*cen2.real()+0.5 : 1000*cen2.real()-0.5;
		//int y1000 = cen2.imag() >= 0 ? 1000*cen2.real()+0.5 : 1000*cen2.real()-0.5;
		//int r1000 = r2          >= 0 ? 1000*r2         +0.5 : 1000*r2         -0.5;
		//printf("%.3f %.3f %.3f", 1.0*x1000/1000, 1.0*y1000/1000, 1.0*r1000/1000);
		//cout<<endl;

	}
	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
#define S second
#define F first
using namespace std;
typedef pair<double,double> P;

double Length(P p,P q){
  return sqrt(pow(p.first - q.first,2)+pow(p.second-q.second,2));
}

int main(){
  P p[3];
  double a,b,c,A,B,C,R,x,y;
  int n;
  cin >> n;
  while(n-- > 0){ 
    cin >> p[0].first >> p[0].second >> p[1].first >>p[1].second >> p[2].first >> p[2].second;
    a = Length(p[0],p[1]);
    b = Length(p[1],p[2]);
    c = Length(p[2],p[0]);
    A = acos((b*b+c*c-a*a)/(2*b*c));
    B = acos((a*a+c*c-b*b)/(2*a*c));
    C = acos((a*a+b*b-c*c)/(2*a*b));
    R = 0.5 * (a/sin(A));
    //x = 0.5*((((pow(p[0].F,2)+pow(p[0].S,2))*(p[1].S-p[2].S)+((pow(p[1].F,2)+pow(p[1].F,2))*(p[2].S-p[0].S))+((pow(p[2].F,2)+pow(p[2].S,2))*(p[0].S-p[1].S))) )   / (p[0].F*(p[1].S-p[2].S)+p[1].F*(p[2].S-p[0].S)+p[2].F*(p[0].S-p[1].S)));
    x = 0.5*( (pow(p[0].F,2)+pow(p[0].S,2))*(p[1].S-p[2].S) + (pow(p[1].F,2)+pow(p[1].S,2))*(p[2].S-p[0].S) + (pow(p[2].F,2)+pow(p[2].S,2))*(p[0].S-p[1].S)                           )/(       
																							 p[0].F*(p[1].S-p[2].S) + p[1].F*(p[2].S-p[0].S) + p[2].F*(p[0].S-p[1].S)            );

    y = 0.5*((pow(p[0].F,2)+pow(p[0].S,2))*(p[1].F-p[2].F)+(pow(p[1].F,2)+pow(p[1].S,2))*(p[2].F-p[0].F)+(pow(p[2].F,2)+pow(p[2].S,2))*(p[0].F-p[1].F))/(p[0].S*(p[1].F-p[2].F)+p[1].S*(p[2].F-p[0].F)+p[2].S*(p[0].F-p[1].F));

    printf("%.3f %.3f %.3f\n",x,y,R);
  }
  return 0;
}