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<stdio.h>
#include<math.h>
int main(){
	int n,x;
	double x1,x2,x3,y1,y2,y3,xp,yp;
	double a1,b1,c1,a2,b2,c2,r;
	scanf("%d",&n);
	for(x=0; x<n; x++)    {
		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;
 xp=(b1*c2-b2*c1)/(a1*b2-a2*b1);
 yp=(c1*a2-c2*a1)/(a1*b2-a2*b1);
 r=((xp-x2)*(xp-x2)+(yp-y2)*(yp-y2));
 r=sqrt(r);
 if(ceil(xp*1000)-xp*1000<=xp*1000-floor(xp*1000)){
	 xp=ceil(xp*1000)/1000;
 }else{
	 xp=floor(xp*1000)/1000;
 }
 if(ceil(yp*1000)-yp*1000<=yp*1000-floor(yp*1000)){
	 yp=ceil(yp*1000)/1000;
 }else{
	 yp=floor(yp*1000)/1000;
 }
 if(ceil(r*1000)-r*1000<=r*1000-floor(r*1000)){
	 r=ceil(r*1000)/1000;
 }else{
	 r=floor(r*1000)/1000;
 }
 printf("%.3f %.3f %.3f\n",xp,yp,r);
	}
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
double dx1, dx2, dx3, dy1, dy2, dy3;

int main(){
	cin >> n;
	REP(i, n){
		cin >> dx1 >> dy1 >> dx2 >> dy2 >> dx3 >> dy3;
		double a = 2 * (dx1 - dx2), b = 2 * (dy1 - dy2), c = (dx1*dx1 + dy1*dy1) - (dx2*dx2 + dy2*dy2);
		double d = 2 * (dx2 - dx3), e = 2 * (dy2 - dy3), f = (dx2*dx2 + dy2*dy2) - (dx3*dx3 + dy3*dy3);
		double x, y;
		if (a < 0){
			a = -a;
			b = -b;
			c = -c;
		}
		if (d < 0){
			d = -d;
			e = -e;
			f = -f;
		}
		if (a == 0){
			y = c / b;
			x = (f - e*y) / d;
		}
		else if (b == 0){
			x = c / a;
			if (d == 0) y = f / e;
			else y = (f - e*x) / d;
		}
		else if (a != 0 && b != 0){
			x = (b*f - c*e) / (b*d - a*e);
			y = (c*d - a*f) / (b*d - a*e);
		}
		cout << fixed << setprecision(3) << x << " " << y << " " << sqrt((dx1 - x)*(dx1 - x) + (dy1 - y)*(dy1 - y)) << endl;
	}
}

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

using namespace std;

struct point{
    double x;
    double y;
};

struct linear{
    double a;
    double b;
    double c;
};

linear get_linear(point a, point b){
    linear l;

    if(a.x == b.x){
        l.a = 1;
        l.b = 0;
        l.c = a.x;
    }else if(a.y == b.y){
        l.a = 0;
        l.b = 1;
        l.c = a.y;
    }else{
        l.a = (b.x-a.x)/(b.y-a.y);
        l.b = -1;
        l.c = a.x * l.a - a.y;
    }
    return l;
}

linear get_linear_vertical(point p, linear l){
    linear lv;
    lv.a = (-1)*l.b;
    lv.b = l.a;
    lv.c = lv.a*p.x + lv.b*p.y;
    return lv;
}

point get_cross_point(linear l1, linear l2){
    point p;
    p.x = (l1.b*l2.c - l1.c*l2.b)/(l1.b*l2.a - l1.a*l2.b);
    p.y = (l1.c*l2.a - l1.a*l2.c)/(l1.b*l2.a - l1.a*l2.b);
    return p;
}

double round3dig(double d){
    d += 0.0005;
    d *= 1000;
    d = int(d);
    if(d != 0)
        d /= 1000;
    return d;
}

int main()
{
    int n;
    point p[3], mp, cp;
    linear l1, l2;

    cin >> n;
    vector< point > v[n];
    for(int i = 0; i < n; ++i){
        cin >> p[0].x >> p[0].y >> p[1].x >> p[1].y >> p[2].x >> p[2].y;
        v[i].push_back(p[0]);
        v[i].push_back(p[1]);
        v[i].push_back(p[2]);
    }
    for(int i = 0; i < n; ++i){
        l1 = get_linear(v[i].at(0), v[i].at(1));
        mp.x = (v[i].at(1).x - v[i].at(0).x)/2;
        mp.y = (v[i].at(1).y - v[i].at(0).y)/2;
        l1 = get_linear_vertical(mp, l1);

        l2 = get_linear(v[i].at(0), v[i].at(2));
        mp.x = (v[i].at(2).x - v[i].at(0).x)/2;
        mp.y = (v[i].at(2).y - v[i].at(0).y)/2;
        l2 = get_linear_vertical(mp, l2);

        cp = get_cross_point(l1, l2);
        cp.x = round3dig(cp.x);
        cp.y = round3dig(cp.y);
        cout << fixed << setprecision(3)
             << cp.x << ' ' << cp.y << endl;
    }
    return 0;
}

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

int main(){

  long double x1,x2,x3,y1,y2,y3;
  long double p,q,r;
  int tmp;
  int n;

  cin >> n;

  while(n--){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    p = ((y1-y3)*(y1*y1 -y2*y2 +x1*x1 -x2*x2) -(y1-y2)*(y1*y1 -y3*y3 +x1*x1 -x3*x3)) / (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));

    q = ((x1-x3)*(x1*x1 -x2*x2 +y1*y1 -y2*y2) -(x1-x2)*(x1*x1 -x3*x3 +y1*y1 -y3*x3)) / (2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3));

    r2 = sqrt((x1-p)*(x1-p) + (y1-q)*(y1-q));

    printf("%.3Lf %.3Lf %.3Lf\n", p, q, 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 = marume(x);
		y = marume(y);
		r = marume(r);
		printf("%.3f %.3f %.3f\n", x, y, r);
	}
	return 0;
}

C++:  /*
Write a program which prints the central coordinate (px, py) and the radius r of a circumscribed circle of a triangle which is constructed by three points (x1, y1)(x2, y2)(x3, y3) on the plane surface.
 */

#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>

using namespace std;

 /*
http://zo3kirin3.net/?p=297
http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q104383420
http://www.nn.iij4u.or.jp/~hsat/misc/math/centre/circumcentre.html
 */

int main() {
	int n; cin >> n;
	vector<double> x(3), y(3), x2(3), y2(3);		// x,yªÀWÌXgAx2,y2ªÀWÌñæÌXg
	
	for (int p=0; p<n; p++) {
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];
		for (int i=0; i<3; i++) {
			x2[i] = x[i]*x[i];
			y2[i] = y[i]*y[i];
		}
		
		// eÓÌ·³ðßéBO½ûÌèðp
		double a, b, c, a2, b2, c2;
		a2 = abs((x[2]-x[1])*(x[2]-x[1]) + (y[2]-y[1])*(y[2]-y[1]));
        b2 = abs((x[0]-x[2])*(x[0]-x[2]) + (y[0]-y[2])*(y[0]-y[2]));
        c2 = abs((x[1]-x[0])*(x[1]-x[0]) + (y[1]-y[0])*(y[1]-y[0]));
		a = sqrt(a2); b = sqrt(b2); c = sqrt(c2);
		
		// ÊÏBwÌö®ðpB
		double s, S2;
		s = (a+b+c) / 2;
		S2 = s+(s-a)+(s-b)+(s-c);
		
		// OSðßéBö®ÍWeby[WðQÆ©xNgâÁÄÈ¢©çà¾Å«È¢c
		double px, py;
		px = (a2*(b2+c2-a2)*x[0] + b2*(c2+a2-b2)*x[1] + c2*(a2+b2-c2)*x[2]) / (16 * S2);
        py = (a2*(b2+c2-a2)*y[0] + b2*(c2+a2-b2)*y[1] + c2*(a2+b2-c2)*y[2]) / (16 * S2);
        
        // oÍB®`µÄoÍ·éB¼aÍ¼üÌûö®ÅB
        cout << setprecision(3) << fixed << px << " " << py << " " << sqrt(abs((px-x[0])*(px-x[0])+(py-y[0])*(py-y[0]))) << endl;
	}
	
	return 0;
}