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 <bits/stdc++.h>
using namespace std;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

#define fr first
#define sc second

double dot(P a, P b) {
    return (a.X * b.X + a.Y * b.Y);
}
double cross(P a, P b) {
    return (a.X * b.Y - a.Y * b.X);
}

int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if( cross(b,c) > EPS ) return +1;
    if( cross(b,c) < -EPS ) return -1;
    if( dot(b,c) < 0 ) return +2;
    if( norm(b) < norm(c) ) return -2;
    return 0;
}

P crossp_ll(P a1, P a2, P b1, P b2) {
    double d1 = cross(b2-b1, b1-a1);
    double d2 = cross(b2-b1, a2-a1);
    if( EQ(d1,0) && EQ(d2,0) ) return a1; // same line
    if( EQ(d2,0) ) assert(false); // precondition not satisfied
    return a1 + d1 / d2 * (a2 - a1);
}

// ????§???¢??????????????? a, b, c ???????????????????????£??????????????????
P circumcenter(P a, P b, P c) {
    a = (a-c) * 0.5;
    b = (b-c) * 0.5;
    return c + crossp_ll(a, a*P(1,1), b, b*P(1,1));
}

int main() {
    int n; cin >> n;
    for(int i=0; i<n; i++) {
        P a, b, c;
        cin >> a.X >> a.Y >> b.X >> b.Y >> c.X >> c.Y;

        double x = abs(a-b), y = abs(b-c) , z = abs(c-a);
        double cos = (x * x + y * y - z * z) / (2 * x * y);
        double sin = sqrt(1 - cos * cos);
        double r = z / sin / 2;

        P s = circumcenter(a,b,c);
        s.X = round(s.X * 1000) / 1000;
        s.Y = round(s.Y * 1000) / 1000;
        r = round(r * 1000) / 1000;
        printf("%.3f %.3f %.3f\n",s.X, s.Y, r);
    }
    return 0;
}

C++: #include <iostream>
#include <math.h>
#include <cstdio>

using namespace std;

int main(void){

  int n;
  cin >> n;

  while(n--){

    double x1,x2,x3;
    double y1,y2,y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    double A1 = 2*(x2 - x1);
    double B1 = 2*(y2 - y1);
    double C1 = pow( x1 , 2 ) - pow( x2 , 2 ) + pow( y1 , 2 ) - pow( y2 , 2);
    double A2 = 2*(x3 - x1);
    double B2 = 2*(y3 - y1);
    double C2 = pow( x1 , 2 ) - pow( x3 , 2 ) + pow( y1 , 2 ) - pow( y3 , 2);
    double x = ( B1*C2 - B2*C1 ) / ( A1*B2 - A2*B1 );
    double y = ( C1*A2 - C2*A1 ) / ( A1*B2 - A2*B1 );
  
  double R = pow( (x - x1) , 2 ) + pow( (y - y1 ) , 2 );
  printf("%.3f %.3f %.3f", x, y, sqrt(R));
  cout << endl;
  }
  return 0;
}

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

using namespace std;

typedef double Real;

Real EPS = 1e-8;

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }
  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
};

struct circle{
  Point p;
  Real r;
  circle(){}
  circle(Point p, Real r) : p(p) , r(r){}
};

circle circumscribed_circle(Point p, Point q, Point r){
  Point a,b,c;
  circle res;
  a=(q-p)*2;
  b=(r-p)*2;
  c.x=p.dot(p)-q.dot(q);  
  c.y=p.dot(p)-r.dot(r);

  //c.x=p.x*p.x-q.x*q.x+p.y*p.y-q.y*q.y;
  //c.y=p.x*p.x-r.x*r.x+p.y*p.y-r.y*r.y;

  res.p.x=a.y*c.y-b.y*c.x;
  res.p.y=b.x*c.x-a.x*c.y;
  res.p=res.p/a.cross(b);
  return circle(res.p, p.dist(res.p));
}

int main(void){
  int n;
  cin >> n;
  while(n--){
    vector<Point>v(3);
    for(int i=0;i<3;i++)
      cin >> v[i].x >> v[i].y;

    circle res=circumscribed_circle(v[0],v[1],v[2]);
    //cout << res.p.x << " " << res.p.y << " " << res.r << endl;
    printf("%.3f %.3f %.3f",res.p.x,res.p.y,res.r);
    cout << endl;
  }
  
  return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    double a[2],b[2],c[2],m[2][2],ans[2],inv[2][2],det,x,y,r;
    cin >>a[0]>>a[1]>>b[0]>>b[1]>>c[0]>>c[1];
    b[0]-=a[0];
    b[1]-=a[1];
    c[0]-=a[0];
    c[1]-=a[1];
    m[0][0] = 2*b[0];
    m[0][1] = 2*b[1];
    m[1][0] = 2*c[0];
    m[1][1] = 2*c[1];
    ans[0] = b[0]*b[0]+b[1]*b[1];
    ans[1] = c[0]*c[0]+c[1]*c[1];
    det = m[0][0]*m[1][1]-m[0][1]*m[1][0];
    inv[0][0] = m[1][1]/det;
    inv[0][1] = -m[0][1]/det;
    inv[1][0] = -m[1][0]/det;
    inv[1][1] = m[0][0]/det;
    x = ans[0]*inv[0][0]+ans[1]*inv[0][1];
    y = ans[0]*inv[1][0]+ans[1]*inv[1][1];
    r = sqrt(x*x+y*y);
    x+=a[0];
    y+=a[1];
    printf("%.3lf %.3lf %.3lf\n",x,y,r);
  }
  return 0;
}

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

int main()
{
	int n;
	double x1[32],x2[32],x3[32],y1[32],y2[32],y3[32],p,q,r;
	double a,b,c;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lf%lf%lf%lf%lf%lf",&x1[i],&x2[i],&x3[i],&y1[i],&y2[i],&y3[i]);
	    p=(y1[i]-y3[i])*(y1[i]*y1[i]-y2[i]*y2[i]+x1[i]*x1[i]-x2[i]*x2[i])-(y1[i]-y2[i])*(y1[i]*y1[i]-y3[i]*y3[i]+x1[i]*x1[i]-x3[i]*x3[i]);
	    p/=(2*(y1[i]-y3[i])*(x1[i]-x2[i])-2*(y1[i]-y2[i])*(x1[i]-x3[i]));
	    q=(x1[i]-x3[i])*(x1[i]*x1[i]-x2[i]*x2[i]+y1[i]*y1[i]-y2[i]*y2[i])-(x1[i]-x2[i])*(x1[i]*x1[i]-x3[i]*x3[i]+y1[i]*y1[i]-y3[i]*y3[i]);
	    q/=(2*(x1[i]-x3[i])*(y1[i]-y2[i])-2*(x1[i]-x2[i])*(y1[i]-y3[i]));
		c=sqrt(fabs((x3[i]-x1[i])*(x3[i]-x1[i])+(y3[i]-y1[i])*(y3[i]-y1[i])));
		b=sqrt(fabs((x3[i]-x2[i])*(x3[i]-x2[i])+(y3[i]-y2[i])*(y3[i]-y2[i])));
		a=sqrt(fabs((x2[i]-x1[i])*(x2[i]-x1[i])+(y2[i]-y1[i])*(y2[i]-y1[i])));
		r=a*b*c/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
		printf("%.3f %.3f %.3f\n",q,p,r);
	}
	return 0;
}
/*?????\???*/