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 <complex>
#include <cstdio>
#include <cmath>
using namespace std;

// ?????§?¨?????????¨??????
typedef complex<double> P;
// ???????????
#define PI 3.1415926535898

// ?¨±?????????????????
#define EPS (1e-10)
//XY??§?¨?
#define X real()
#define Y imag()
	
// ????§???¢?????????
class Triangle{

private:
	//????§???¢??????????????§?¨?
	P a, b, c;
	//????§???¢??????????????????
	double edgeA,edgeB,edgeC;
	//????§???¢???????§??????§??????(????????¢???)
	double angleA,angleB,angleC;
	//????????????????????????????§????????±?????????¢??°
	double LawOfCosines(double a,double b, double c){
		return acos( (b*b+c*c-a*a) / (2.0*b*c) );
	}
	//?????????double????????°???????????????????????????
	bool equal(double a, double b){
		return (abs( a-b ) < EPS)? true : false ;
	}

public:
	//?????????????????????(??????????????¨?????¨?§????????????????)
	Triangle(P p1, P p2, P p3){
		a = p1;
		b = p2;
		c = p3;
		edgeB = abs(c-a);
		edgeA = abs(b-c);
		edgeC = abs(a-b);
		angleA = LawOfCosines(edgeA,edgeB,edgeC);
		angleB = LawOfCosines(edgeB,edgeC,edgeA);
		angleC = LawOfCosines(edgeC,edgeA,edgeB);
	}
	
	double circumscribedCircleRadius(){//?????\?????????????????????
		return ( edgeA / sin(angleA) / 2.0 );
	}
	double circumscribedCircleX(){//??????(?????\????????????)???X??§?¨??????????
		double A = sin(2.0*angleA);
		double B = sin(2.0*angleB);
		double C = sin(2.0*angleC);
		return ( (a.X * A + b.X * B + c.X * C) / (A+B+C) );
	}
	double circumscribedCircleY(){//??????(?????\????????????)???Y??§?¨??????????
		double A = sin(2.0*angleA);
		double B = sin(2.0*angleB);
		double C = sin(2.0*angleC);
		return ( (a.Y * A + b.Y * B + c.Y * C) / (A+B+C) );
	}
};

int main(){
	int n;
	double x1, x2, x3, y1, y2, y3;
	double r, xp, yp;

	scanf("%d", &n);
	for (int i=0 ; i<n ; i++){
		scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
		P a( x1 , y1 );
		P b( x2 , y2 );
		P c( x3 , y3 );
		Triangle Tr(a,b,c);
		r  = Tr.circumscribedCircleRadius();
		xp = Tr.circumscribedCircleX();
		yp = Tr.circumscribedCircleY();
		printf("%.3f %.3f %.3f\n", xp,yp,r);
	}
}

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

int main(){
	int n;
	cin >> n;
	double x[n], y[n], r[n];
	for(int i = 0; i < n; i++){
		double x1, y1, x2, y2, x3, y3;
		double a, b, c, d, e, f;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		a = 2*(x1-x2);
		b = 2*(y1-y2);
		c = 2*(x2-x3);
		d = 2*(y2-y3);
		e = x1*x1-x2*x2+y1*y1-y2*y2;
		f = x2*x2-x3*x3+y2*y2-y3*y3;
		x[i] = (d*e-b*f)/(a*d-c*d);
		y[i] = (a*f-c*e)/(a*d-b*c);
		r[i] = sqrt((x[i]-x1)*(x[i]-x1)+(y[i]-y1)*(y[i]-y1));
	}
	for(int i = 0; i < n; i++){
		cout <<  fixed << setprecision(3) << x[i] << " " << y[i] << " " << r[i] << endl;
	}
}

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

const double EPS = 1e-4;

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

int main() {
  int n;
  double x[3], y[3], a, b, c, sa, ca;
  double px, py, r;
  cin >> n;
  for (int k=0;k<n;k++) {
    for (int i=0;i<3;i++) {
      cin >> x[i] >> y[i];
    }
    a = dist(x[1], y[1], x[2], y[2]);
    b = dist(x[0], y[0], x[1], y[1]);
    c = dist(x[0], y[0], x[2], y[2]);
    ca = (a*a - b*b - c*c) / (2*b*c);
    sa = sqrt(1 - ca*ca);
    r = a / sa / 2;

    for (px=-r;px<=r;px+=0.0001) {
      py = sqrt(r*r - px*px);
      if (abs(pow(px-x[0], 2) + pow(py-y[0], 2) - r*r) < EPS &&
          abs(pow(px-x[1], 2) + pow(py-y[1], 2) - r*r) < EPS &&
          abs(pow(px-x[2], 2) + pow(py-y[2], 2) - r*r) < EPS) {
        break;
      }
    }
    printf("%.3f %.3f %.3f\n", px, py, r);
  }
  return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdip>
#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;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <stdio.h>

using namespace std;

struct point {
	double x;
	double y;
};

struct circle {
	point center;
	double radius;
};

struct line { // ax + by + c = 0
	double a;
	double b;
	double c;
};

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

bool operator == (const point& p1, const point& p2)
{
	return p1.x == p2.x && p1.y == p2.y;
}

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

bool get_crosspoint(const line& l1, const line& l2, point *result)
{
	double denominator = l1.a * l2.b - l1.b * l2.a;
	if (denominator == 0) {
		return false;
	}
	result->x = (l1.b * l2.c - l2.b * l1.c) / denominator;
	result->y = (l2.a * l1.c - l1.a * l2.c) / denominator;
	return true;
}

bool get_bisector(const point& p1, const point& p2, line *result)
{
	if (p1 == p2) {
		return false;
	}
	result->a = 2 * (p1.x - p2.x);
	result->b = 2 * (p1.y - p2.y);
	result->c = -(p1.y - p2.y) * (p1.y + p2.y) - (p1.x - p2.x) * (p1.x + p2.x);
	return true;
}

bool get_circum_circle(const point& p1, const point& p2, const point& p3, circle *result)
{
	double a = get_distance(p1, p2);
	double b = get_distance(p2, p3);
	double c = get_distance(p3, p1);

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

	line line_p1p2;
	line line_p2p3;

	// 頂点の垂直2等分線の交点が外心
	return get_bisector(p1, p2, &line_p1p2) &&
		   get_bisector(p2, p3, &line_p2p3) &&
		   get_crosspoint(line_p1p2, line_p2p3, &result->center);
}

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

	get_circum_circle(p1, p2, p3, &result);
	return result;
}

int main(void)
{
	int n;

	std::cin >> n;

	while (n--) {
		circle c = get_circum_circle(std::cin);
		printf("%.3f %.3f %.3f\n", c.center.x, c.center.y, c.radius);
	}
	return 0;
}