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 <cmath>

int main()
{
        int n;
        double x1, x2, x3, y1, y2, y3, a, b, c, r;
        std::cin >> n;
        std::cout.precision(3);
        std::cout.setf(std::ios::fixed);
        while(n--)
        {
                std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
                a = (x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2);
                b = (x1 - x3)*(x1 - x3) + (y1 - y3)*(y1 - y3);
                c = (x2 - x3)*(x2 - x3) + (y2 - y3)*(y2 - y3);
                r = -(a*a + b*b + c*c - 2*a*b - 2*b*c - 2*c*a);
                std::cout << (a*(-a+b+c)*x3 + b*(a-b+c)*x2 + c*(a+b-c)*x1)/r << " " << (a*(-a+b+c)*y3 + b*(a-b+c)*y2 + c*(a+b-c)*y1)/r << " " << sqrt(a*b*c/r) << std::endl;
        }
        return 0;
}

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

struct TPoint
{
    double x;
    double y;
};
struct TTriangle
{
    TPoint p1;
    TPoint p2;
    TPoint p3;
};
void SolveEquation(double a, double b, double c, double d, double e, double f, double* x, double* y)
{
    *y = (f - d * c / a)/( e - d * b / a);
    *x = (c - b * *y) / a;
}
/*
A(a, b) B(c, d) C(e, f)
(OA)^2 = (OB)^2
(OA)^2 = (OC)^2
x2-2ax+a2 + y2-2by+b2 = x2-2cx+c2 + y2-2dy+d2
(2c-2a)x + (2d-2b)y = c^2 + d^2 - a^2 - b^2;

x2-2ax+a2 + y2-2by+b2 = x2-2ex+e2 + y2-2fy+f2
(2e-2a)x + (2f-2b)y = e^2 + f^2 - a^2 - d^2
*/
TPoint GetCentral(const TTriangle& Tri)
{
    using std::pow;
    double a, b, c, d, e, f;
    a = 2 * (Tri.p2.x - Tri.p1.x);
    b = 2 * (Tri.p2.y - Tri.p1.y);
    c = pow(Tri.p2.x,2) + pow(Tri.p2.y,2) - pow(Tri.p1.x,2) - pow(Tri.p1.y,2);
    d = 2 * (Tri.p3.x - Tri.p1.x);
    e = 2 * (Tri.p3.y - Tri.p1.y);
    f = pow(Tri.p3.x,2) + pow(Tri.p3.y,2) - pow(Tri.p1.x,2) - pow(Tri.p1.y,2);
    TPoint P;
    SolveEquation(a, b, c, d, e, f, &P.x, &P.y);
    return P;
}
double GetLength(const TPoint& A, const TPoint& B)
{
    using namespace std;
    return sqrt(pow(A.x - B.x, 2) + pow(A.y - B.y, 2));
}
double GetRadius(const TTriangle& Tri)
{
    double a = GetLength(Tri.p1, Tri.p2);
    double b = GetLength(Tri.p2, Tri.p3);
    double c = GetLength(Tri.p3, Tri.p1);
    
    return (a*b*c)/std::sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
}
int main()
{
    int n;
    std::cin >> n;
    for(int i = 0; i < n; ++i){
        TTriangle tri;
        std::cin >> tri.p1.x >> tri.p1.y >> tri.p2.x >> tri.p2.y >> tri.p3.x >> tri.p3.y;
        TPoint C = GetCentral(tri);
        double r = GetRadius(tri);
        std::cout << std::fixed << std::setprecision(3);
        std::cout << C.x << " " << C.y << " " << r << std::endl;
        
    }
    return 0;
}

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

using namespace std;

#define SQ(x) ((x) * (x))

double ix[4], iy[4], x[4], y[4], a[4], b[4], c[4];

void equation(double x1, double y1, double x2, double y2, double *equa, double *equb)
{
  if(x1 == x2){
    *equb = 0;
    return;
  }
  if(y1 == y2){
    *equa = 0;
    return;
  }

  *equa = (y1 - y2) / (x1 - x2);
  return;
}

void line(double cx, double cy, double *equa, double *equb, double *equc)
{
  //  printf("%lf %lf %lf %lf %lf\n", cx, cy, *equa, *equb, *equc);
  if(*equa == 0){
    *equa = 1;
    *equb = 0;
    *equc = cx;
    //    printf("x = %lf\n", *equc);
    return;
  }
  if(*equb == 0){
    *equa = 0;
    *equb = 1;
    *equc = cy;
    //    printf("y = %lf\n", *equc);
    return;
  }

  *equa = -1 / *equa;
  *equc = cy - (*equa) * cx;
  return;
}

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

void point(double a1, double b1, double c1, double a2, double b2, double c2, double *rx, double *ry)
{
  if(!a1 || !b1 || !a2 || !b2 ){
    if(!a1 && !b2){
      *rx = c2;
      *ry = c1;
      return;
    }
    if(!b1 && !a2){
      *rx = c1;
      *ry = c2;
      return;
    }

    if(!a1){
      //      puts("a");
      *ry = c1;
      *rx = ((*ry) - c2) / a2;
      return;
    }
    if(!a2){
      //      puts("a");
      *ry = c2;
      *rx = ((*ry) - c1) / a1;
      return;
    }
    /*    if(!a1 || !a2){
      puts("a");
      double aa = (a1 * b2) - (a2 * b1);
      double cc = (c1 * b2) - (c2 * b1);
      *rx = -(cc / aa);
      *ry = a1 * (*rx) + c1;
      return;
      }*/

    if(!b1){
      //      puts("b1");
      *ry = (a2 * c1 + c2) / b2;
      *rx = a1;
      return ;
    }
    if(!b2){
      //      puts("b2");
      *ry = (a1 * c2 + c1) / b1;
      *rx = a2;
      return;
    }
    /*    if(!b1 || !b2){
      puts("b");
      double bb = (b1 * a2) - (b2 * a1);
      double cc = (c1 * a2) - (c2 * a1);
      *ry = cc / bb;
      *rx = ((*ry) * b1 - c1) / a1;
      return;
      }*/

    fprintf(stderr, "error\n");
    return;
  }

  double bb = (b1 * a2) - (b2 * a1);
  double cc = (c1 * a2) - (c2 * a1);
  *ry = cc / bb;
  *rx = ((*ry) * b1 - c1) / a1;
  return;
}

int main()
{
  int n;
  scanf("%d", &n);
  while(n--){
    for(int i=0;i<3;i++)
      scanf("%lf%lf", &ix[i], &iy[i]);
    //    printf("%lf %lf %lf %lf %lf %lf\n", ix[0], ix[1], ix[2], iy[0], iy[1], iy[2]);    
    a[0] = a[1] = b[0] = b[1] = 1;
    c[0] = c[1] = 0;
    equation(ix[0], iy[0], ix[1], iy[1], &a[0], &b[0]);
    equation(ix[1], iy[1], ix[2], iy[2], &a[1], &b[1]);

    //    printf("傾き %lf %lf %lf %lf\n", a[0], b[0], a[1], b[1]);


    line((ix[0]+ix[1])/2, (iy[0]+iy[1])/2, &a[0], &b[0], &c[0]);
    line((ix[1]+ix[2])/2, (iy[1]+iy[2])/2, &a[1], &b[1], &c[1]);

    //    printf("line %lf %lf %lf %lf %lf %lf\n", a[0], b[0], c[0], a[1], b[1], c[1]);
    
    double resx, resy;
    point(a[0], b[0], c[0], a[1], b[1], c[1], &resx, &resy);

    printf("%.3lf %.3lf %.3lf\n", resx, resy, dist(resx, resy, ix[0], iy[0]));
    //    printf("%lf %lf\n", dist(resx, resy, ix[1], iy[1]), dist(resx, resy, ix[2], iy[2]));
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    
    cin >> n;
    
    for (int i = 0; i < n; i++)
    {
        double x1, y1, x2, y2, x3, y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        
        double a1, a2, b1, b2, c1, c2;
        a1 = (x2 - x1) * 2;
        b1 = (y2 - y1) * 2;
        c1 = x2 * x2  + y2 * y2 - x1 * x1 - y1 * y1;
        a2 = (x3 - x1) * 2;
        b2 = (y3 - y1) * 2;
        c2 = x3 * x3  + y3 * y3 - x1 * x1 - y1 * y1;
        
        double x, y, r;
        x = ((c1 * b2) - (c2 * b1)) / ((a1 * b2) - (a2 * b1));
        y = ((a1 * c2) - (a2 * c1)) / ((a1 * b2) - (a2 * b1));
        r = sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
        
        cout << setprecision(3) << fixed << x << " " << y << " " << r << endl;
    }
    
    return 0;
}