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 <cstdio>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		double x1,y1,x2,y2,x3,y3,xp,yp,r;
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		xp=0;
		yp=0;
		double a=y2-y1,b=y3-y1,c=y2-y3,d=x2-x1,e=x3-x1;
		if(y1 != y2 && y1 != y3){
			xp=(c/2-e*(x1+x3)/2/b-d*(x2+x1)/2/a)/(-e/b+d/a);
			yp=-e/b*(xp-(x1+x3)/2)+(y1+y3)/2;
		}else if(y1==y2){
			xp=(x1+x2)/2;
			yp=-e/b*(xp-(x1+x3)/2)+(y1+y3)/2;
		}else if(y1==y3){
			xp=(x1+x3)/2;
			yp=-d/a*(xp-(x1+x2)/2)+(y1+y2)/2;
		}
		r = sqrt((x1-xp)*(x1-xp)+(y1-yp)*(y1-yp));
		xp*=1000;
		if(xp>0)
			xp+=0.5;
		else
			xp-=0.5;
		int xp2=xp;
		yp*=1000;
		if(yp>0)
			yp+=0.5;
		else
			yp-=0.5;
		int yp2=yp;
		printf("%.3lf %.3lf %.3lf\n",xp2/(double)1000,yp2/(double)1000,r);
	}
	return 0;
}

C++: #include <bits/stdc++.h>  
 
using namespace std;
 
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
	int N;
	scanf("%d", &N);
	rep(i, N) {
		double x1, y1, x2, y2, x3, y3;
		scanf("%lf %lf %lf %lf %lf %lf", &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 p = (b * f - c * e)/(a * e - d * b);
	    double q = (a * f - c * d)/(b * d - a * e);
		double r1 = sqrt( pow( p - x1, 2 ) + pow( q - y1, 2 ) );
        double r2 = sqrt( pow( p - x2, 2 ) + pow( q - y2, 2 ) );
        double r3 = sqrt( pow( p - x3, 2 ) + pow( q - y3, 2 ) );
        double r = ( r1 + r2 + r3 ) / 3.0;
		printf("%.3f %.3f %.3f\n", p, q, r);
	}
	return 0;
}

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

using namespace std;

long double sisya(long double a) {
	stringstream ss;
	string k;
	ss << a;
	ss >> k;
	if  (k.find('.') != string::npos) {
		int r = k.find('.');
		if (r+4 <= k.size() && k[r+4]-'0' >= 5) {
			a += 0.001;
		}
	}
	return a; 
}

double ll(double x1, double y1, double x2, double y2) {
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

double yoge(double a, double b, double c) {
	return (b*b+c*c-a*a)/(2.0*b*c);
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		long double dd[3][2];
		for (int j = 0; j < 3; j++) {
			cin >> dd[j][0] >> dd[j][1];
		}
		long double s[3];
		s[0] = ll(dd[1][0],dd[1][1],dd[2][0],dd[2][1]);
		s[1] = ll(dd[2][0],dd[2][1],dd[0][0],dd[0][1]);
		s[2] = ll(dd[0][0],dd[0][1],dd[1][0],dd[1][1]);
		long double k[3];
		k[0] = acos(yoge(s[0],s[1],s[2]));
		k[1] = acos(yoge(s[1],s[2],s[0]));
		k[2] = acos(yoge(s[2],s[0],s[1]));
		long double X, Y, R;
		X = (dd[0][0]*sin(2.0*k[0])+dd[1][0]*sin(2.0*k[1])+dd[2][0]*sin(2.0*k[2]))/(sin(2.0*k[0])+sin(2.0*k[1])+sin(2.0*k[2]));
		Y = (dd[0][1]*sin(2.0*k[0])+dd[1][1]*sin(2.0*k[1])+dd[2][1]*sin(2.0*k[2]))/(sin(2.0*k[0])+sin(2.0*k[1])+sin(2.0*k[2]));
		R = s[0]/(2.0*sin(k[0]));
		X = sisya(X);
		Y = sisya(Y);
		R = sisya(R);
		printf("%.3f %.3f %.3f\n", X, Y, R);
	}
	return 0;
}

C++: #include <cmath>
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int n;
  double x1,y1,x2,y2,x3,y3,p,p1,p2,q,q1,q2,r;
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    p1 = (x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1) * (y3 - y1) - (x3 * x3 - x1 * x1 + y3 * y3 - y1 * y1) * (y2 - y1);
    p2 = 2 * (x1 * y2 - x1 * y3 + x2 * y3 - x2 * y1 + x3 * y1 - x3 * y2);
    p = p1 / p2;
    q1 = (y2 * y2 - y1 * y1 + x2 * x2 - x1 * x1) * (x3 - x1) - (y3 * y3 - y1 * y1 + x3 * x3 - x1 * x1) * (x2 - x1);
    q2 =  2 * (y1 * x2 - y1 * x3 + y2 * x3 - y2 * x1 + y3 * x1 - y3 * x2);
    q = q1 / q2;
    r = sqrt((x1-p) * (x1-p) + (y1-q) * (y1-q) );
    p *= 1000;
    p += 0.5;
    p = floor(p);
    p /= 1000;
    q *= 1000;
    q += 0.5;
    q = floor(q);
    q /= 1000;
    r *= 1000;
    r += 0.5;
    r = floor(r);
    r /= 1000;
    printf("%.3f %.3f %.3f", p, q, r);
  }
}

C++: #! -*- coding:utf-8 -*-
import math
n = input()
for x in xrange(n):
    x1,y1,x2,y2,x3,y3 = map(float,raw_input().split())
    a1 = 2.0*(x2-x1)
    b1 = 2.0*(y2-y1)
    x12 = x1**2
    y12 = y1**2
    c1 = x12-x2**2+y12+y2**2
    a2 = 2.0*(x3-x1)
    b2 = 2.0*(y3-y1)
    c2 = x12-x3**2+y12-y3**2
    denom=(a1*b2-a2*b1)
    x = (b1*c2-b2*c1)/denom
    y = (c1*a2-c2*a1)/denom
    r = math.sqrt((x-x1)**2+(y-y1)**2)

    print "%.3f %.3f %.3f"%(x,y,r)