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 <vector>
#include <cmath>
#include <iomanip>

using namespace std;

double radius(vector<double> center, vector<double> xy){
    double x, y;
    x = xy[0] - center[0];
    y = xy[1] - center[1];
    return sqrt(pow(x,2) + pow(y,2));    
}

vector<double> center(vector<double> coo){
    double a1, b1, c1, a2, b2, c2, x, y;
    a1 = 2 * (coo[2] - coo[0]);
    b1 = 2 * (coo[3] - coo[1]);
    c1 = pow(coo[0],2) - pow(coo[2],2) + pow(coo[1],2) - pow(coo[3],2); 
    
    a2 = 2 * (coo[4] - coo[0]);
    b2 = 2 * (coo[5] - coo[1]);
    c2 = pow(coo[0],2) - pow(coo[4],2) + pow(coo[1],2) - pow(coo[5],2);
    
    x = (b1*c2 - b2*c1) / (a1*b2 - a2*b1);
    y = (c1*a2 - c2*a1) / (a1*b2 - a2*b1);
    
    vector<double> cent = {x,y};
    double rad = radius(cent, coo);
    return {x,y, rad};
    
}



int main(){
    int n;
    vector<double> v = {0,0,0,0,0,0};
    cin >> n;
    while(cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4] >> v[5]){
        vector<double> c = center(v);
        cout << fixed << setprecision(3) << c[0] << " " << c[1] << " " << c[2] << endl;
    }
}

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);
	}
}