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 <algorithm>
#include <cassert>
#include <cmath>
#include <stdio.h>

using namespace std;

//-------------------------------------------------------------------------
// geometric library

struct point {
	double x;
	double y;
};

struct circle {
	point center;
	double radius;
};

double get_distance(const point& p1, const point& p2)
{
	return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}

point get_midpoint(const point& p1, const point& p2)
{
	point mid;
	mid.x = p1.x + p2.x / 2.0;
	mid.y = p1.y + p2.y / 2.0;
	return mid;
}

std::istream& operator >> (std::istream& is, point& p)
{
	is >> p.x >> p.y;
	return is;
}

//-------------------------------------------------------------------------
// solution

// 外接円を求める
circle get_circum_circle(const point& p1, const point& p2, const point& p3)
{
	double a = get_distance(p1, p2);
	double b = get_distance(p2, p3);
	double c = get_distance(p3, p1);
	circle result;

	// 半径の公式
	result.radius = a * b * c / sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));

	// c,p1,p2のなす角
	double theta = acos((a / 2.0) / result.radius);

	result.center.x = p1.x + result.radius * cos(theta);
	result.center.y = p1.y + result.radius * sin(theta);

	return result;
}

circle get_circum_circle(istream& is)
{
	point p1, p2, p3;
	is >> p1 >> p2 >> p3;
	return get_circum_circle(p1, p2, p3);
}

int main(void)
{
	int num_cases;

	std::cin >> num_cases;

	for (int i = 0; i < num_cases; i++) {		
		circle result = get_circum_circle(std::cin);
		printf("%.3f %.3f %.3f\n", result.center.x, result.center.y, result.radius);
	}
	return 0;
}

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

int main(void) {

  int data;
  double x1,y1,x2,y2,x3,y3;

  double x12,y12,x13,y13;
  double ang12,ang13;
  double xp,yp,r;

  int flag;
  int i;

  scanf("%d",&data);

  for(i=0;i<data;i++) {
    flag=1;
    scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);

    x12=(x1+x2)/2.0;
    y12=(y1+y2)/2.0;
    x13=(x1+x3)/2.0;
    y13=(y1+y3)/2.0;

    if(y1==y2) {

      xp=x12;

      ang13=-(x3-x1)/(y3-y1);

      yp=ang13*(xp-x13)+y13;

      flag=0;

    }

    if(y1==y3) {

      xp=x13;
      
      ang12=-(x2-x1)/(y2-y1);

      yp=ang12*(xp-x12)+y12;

      flag=0;

    }

    if(flag==1) {

      ang12=-(x2-x1)/(y2-y1);
      ang13=-(x3-x1)/(y3-y1);

      xp=(ang12*x12-ang13*x13-y12+y13)/(ang12-ang13);

      yp=ang12*(xp-x12)+y12;
    
    }

    r=sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));

    printf("%lf %lf %lf\n",xp,yp,r);
  }

  return 0;
  
}

C++: // AOJ 0010 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0010&lang=jp)
#include<cstdio>
#include<cmath>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;

double sqr( double x )
{ return x*x; }

int main()
{
	scanf( "%d", &n );
	while( n-- )
	{
		double x1, y1, x2, y2, x3, y3;
		scanf( "%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3 );

		double a = sqrt(sqr(x3-x2)+sqr(y3-y2)), b = sqrt(sqr(x1-x3)+sqr(y1-y3)), c = sqrt(sqr(x2-x1)+sqr(y2-y1));
		double cosA = (sqr(b)+sqr(c)-sqr(a))/(sqr(b)+sqr(c)), cosB = (sqr(c)+sqr(a)-sqr(b))/(sqr(c)+sqr(a)), cosC = (sqr(a)+sqr(b)-sqr(c))/(sqr(a)+sqr(b));
		double sinA = sqrt(1-sqr(cosA)), sinB = sqrt(1-sqr(cosB)), sinC = sqrt(1-sqr(cosC));
		double sin2A = 2*sinA*cosA, sin2B = 2*sinB*cosB, sin2C = 2*sinC*cosC;
		double px = (sin2A*x1+sin2B*x2+sin2C*x3)/(sin2A+sin2B+sin2C), py = (sin2A*y1+sin2B*y2+sin2C*y3)/(sin2A+sin2B+sin2C);

		printf( "%.3f %.3f %.3f\n", px, py, sqrt(sqr(x1-px)+sqr(y1-py)) );
	}

	return 0;
}

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

using namespace std;
struct point{
	double x, y;
};
struct circle{
	point p;
	double r;
};

circle circumscribed_circle(point p, point q, point r){
	double a[2],b[2],c[2];
	circle res;
     
    a[0]=2*(q.x-p.x);
    b[0]=2*(q.y-p.y);
    c[0]=p.x*p.x-q.x*q.x+p.y*p.y-q.y*q.y;
     
    a[1]=2*(r.x-p.x);
    b[1]=2*(r.y-p.y);
    c[1]=p.x*p.x-r.x*r.x+p.y*p.y-r.y*r.y;
     
    res.p.x=(b[0]*c[1]-b[1]*c[0])/(a[0]*b[1]-a[1]*b[0]);
    res.p.y=(c[0]*a[1]-c[1]*a[0])/(a[0]*b[1]-a[1]*b[0]);
  
    res.r=sqrt(pow(fabs(p.x-res.p.x),2)+pow(fabs(p.y-res.p.y),2));
     
    return res;
}

int main(){
	int n;
	point in[3];
	circle ans;
	cin>>n;
	for(;n--;){
		for(int i=0;i<3;i++)
			cin >> in[i].x >> in[i].y;
		ans = circumscribed_circle(in[0], in[1], in[2]);
		printf("%.3f %.3f %.3f\n",ans.p.x,ans.p.y,ans.r);
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<stack>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

struct Coor{
	double x,y;
};

struct Ans2{
	double l,m;
};

struct Ans3{
	double l,m,n;
	Ans3(Ans2 a){
		l=a.l; m=a.m;
	}
};

Ans2 solve2(double l[2],double m[2],double n[2]){
	/*for(int i=0;i<2;i++){
		printf("(%lfl)+(%lfm)+n = (%lf)\n",l[i],m[i],n[i]);
	}*/
	Ans2 ans;
	double a,b;
	a = l[0]*m[1]-l[1]*m[0]; b = n[0]*m[1]-n[1]*m[0];
	ans.l = b/a;
	//printf("%lfx = %lf\n",a,b);
	a = m[0]*l[1]-m[1]*l[0]; b = n[0]*l[1]-n[1]*l[0];
	ans.m = b/a;
	//printf("%lfy = %lf\n",a,b);
	return ans;
}

Ans3 solve3(double l[3],double m[3],double n[3]){
	double _l[2],_m[2],_n[2];
	_l[0] = l[0]-l[1]; _l[1] = l[0]-l[2];
	_m[0] = m[0]-m[1]; _m[1] = m[0]-m[2];
	_n[0] = n[0]-n[1]; _n[1] = n[0]-n[2];
	Ans3 ans = Ans3(solve2(_l,_m,_n));
	ans.n = n[0]-(l[0]*ans.l+m[0]*ans.m);
	return ans;
}

int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		Coor in[3];
		double l[3],m[3],n[3];
		for(int i=0;i<3;i++){
			cin>>in[i].x>>in[i].y;
			l[i] = in[i].x;
			m[i] = in[i].y;
			n[i] = -(in[i].x*in[i].x+in[i].y*in[i].y);
			//printf("(%lfl)+(%lfm)+n = (%lf)\n",l[i],m[i],n[i]);
		}
		Ans3 ans3 = solve3(l,m,n);
		//printf("l = %lf, m = %lf, n = %lf\n",ans3.l,ans3.m,ans3.n);
		double r = sqrt(-(ans3.n-ans3.l/2*ans3.l/2-ans3.m/2*ans3.m/2));
		printf("%.3lf %.3lf %.3lf\n",-ans3.l/2,-ans3.m/2,r);
	}
}

C++: #include <iostream>
#include <cstdio>
#include <math.h>
using namespace std;

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

void solve(double x1, double y1, double x2, double y2, double x3, double y3){
	double a,b,c,ans_x,ans_y,ans_r;
	a = l(x1, y1, x2, y2);
	b = l(x1, y1, x3, y3);
	c = l(x2, y2, x3, y3);
	double A,B,C;
	A=a*a;
	B=b*b;
	C=c*c;
	
	double s = (a+b+c)/2.0;
	double S = sqrt(s*(s-a)*(s-b)*(s-c));
	double largeSd = S*S;
	ans_x = A/4.0*(B+C-A)/4.0*x1/largeSd + B/4.0*(C+A-B)/4.0*x2/largeSd + C/4.0*(A+B-C)/4.0*x3/largeSd;
	ans_y = A/4.0*(B+C-A)/4.0*y1/largeSd + B/4.0*(C+A-B)/4.0*y2/largeSd + C/4.0*(A+B-C)/4.0*y3/largeSd;
	
	ans_r = l(x1, y1, ans_x, ans_y);
	printf("%4.3f %4.3f, %4.3f\n",ans_x, ans_y, ans_r);
}

int main(){
	int n;
	cin >> n;
	double x1[n],y1[n],x2[n],y2[n],x3[n],y3[n];
	for(int i = 0; i < n; i++){
		cin >> x1[i] >> y1[i] >> x2[i] >> y2[i] >> x3[i] >> y3[i];
	}
	for(int i = 0; i < n; i++){
		solve(x1[i], y1[i], x2[i], y2[i], x3[i], y3[i]);
	}
}