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>
#include <cstdio>

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    std::cin >> n;
    while (n--) {
        /* A(x1, y1)
         * B(x2, y2)
         * C(x3, y3)
         * */
        double x1, y1, x2, y2, x3, y3;
        double px, py, r;
        double radA, radB, radC;
        double a, b, c;
        std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        a = std::sqrt(std::pow(x3 -  x2, 2) + std::pow(y3 - y2, 2));
        b = std::sqrt(std::pow(x1 -  x3, 2) + std::pow(y1 - y3, 2));
        c = std::sqrt(std::pow(x2 -  x1, 2) + std::pow(y2 - y1, 2));
        radA = std::acos((b*b + c*c - a*a) / (2*b*c));
        radB = std::acos((c*c + a*a - b*b) / (2*c*a));
        radC = std::acos((a*a + b*b - c*c) / (2*a*b));
        double sin2A = std::sin(2*radA);
        double sin2B = std::sin(2*radB);
        double sin2C = std::sin(2*radC);
        px = (sin2A*x1 + sin2B*x2 + sin2C*x3) / (sin2A + sin2B + sin2C);
        py = (sin2A*y1 + sin2B*y2 + sin2C*y3) / (sin2A + sin2B + sin2C);
        r = a / (2 * std::sin(radA));
        std::printf("%.3lf %.3lf %.3lf\n", px, py, r);
        //std::printf("(x1,y1)=(%.1lf,%.1lf)\n(x2,y2)=(%.1lf,%.1lf)\n(x3,y3)=(%.1lf,%.1lf)\n", x1, y1, x2, y2, x3, y3);
        //std::printf("a:%.3lf b:%.3lf c:%.3lf\n", a, b, c);
        //std::printf("radA:%.3lf radB:%.3lf radC:%.3lf\n", radA, radB, radC);
        //std::printf("A:%.3lf B:%.3lf C:%.3lf\n", radA * 180 / M_PI, radB * 180 / M_PI, radC * 180 / M_PI);
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

typedef unsigned long long ull;

struct P{
    double x, y;
    double size(){
        return std::sqrt(x*x + y*y);
    }
    double sizeS(){
        return x*x + y*y;
    }
};

P operator+(const P& lp, const P& rp){
    return {lp.x+rp.x, lp.y+rp.y};
}

P operator-(const P& lp, const P& rp){
    return {lp.x-rp.x, lp.y-rp.y};
}

P operator*(const P& p, const double& k){
    return {k*p.x, k*p.y};
}

double cross(const P& lp, const P& rp){
    return lp.x * rp.y - lp.y * rp.x;
}

int main(){
    int N;
    std::cin >> N;

    REP(i, N){
        P A, B, C, v1, v2, v3;
        std::cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
        v1 = B - A; v2 = C - A, v3 = B - C;

        double sinA = std::abs(cross(v1, v2)) / (v1.size() * v2.size()),
            r = v3.size() / 2.0 / sinA;

        double x = 0.5 * ((A.y-C.y)*(A.sizeS()-B.sizeS()) - (A.y-B.y)*(A.sizeS()-C.sizeS())) / ((A.x-B.x)*(A.y-C.y)-(A.x-C.x)*(A.y-B.y)),
            y = 0.5 * ((A.x-C.x)*(A.sizeS()-B.sizeS()) - (A.x-B.x)*(A.sizeS()-C.sizeS())) / ((A.y-B.y)*(A.x-C.x)-(A.y-C.y)*(A.x-B.x));

        printf("%.3f %.3f %.3f\n", x, y, r);
    }
}

C++: #include <iostream>
#include <iomanip>
#include <cmath>
int main()
{
  int n;
  std::cin >> n;
  while (n--) {
    double x1, y1, x2, y2, x3, y3, px, py, r;
    std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double c = 2.0 * ((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1));
    px = ((y3 - y1) * (x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1) +
          (y1 - y2) * (x3 * x3 - x1 * x1 + y3 * y3 - y1 * y1)) / c;
    py = ((x1 - x3) * (x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1) +
          (x2 - x1) * (x3 * x3 - x1 * x1 + y3 * y3 - y1 * y1)) / c;
    r = std::sqrt(std::pow(x1 - px, 2) + std::pow(y1 - py, 2));
    std::cout << std::fixed << std::setprecision(3) << px << " " <<
      py << " " << r << std::endl;
  }
  return 0;
}

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

int main()
{
	int n;
	double x1,y1,x2,y2,x3,y3,xp,xp1,xp2,yp1,yp2,yp,r;
	scanf("%d",&n);

	for(int x=0;x<n;x++)
	{
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
		xp1=(y1-y3)*(y1*y1 -y2*y2 +x1*x1 -x2*x2) -(y1-y2)*(y1*y1 -y3*y3 +x1*x1 -x3*x3);
		xp2=2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3);
		xp=xp1/xp2;
		yp1=(x1-x3)*(x1*x1 -x2*x2 +y1*y1 -y2*y2) -(x1-x2)*(x1*x1 -x3*x3 +y1*y1 -y3*y3);
		yp2=2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3);
		yp=yp1/yp2;

		r=(x3-xp)*(x3-xp)+(y3-yp)*(y3-yp);
		r=sqrt(r);
		printf("%.3f %.3f %.3f\n",xp,yp,r);
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <queue>
#include <cmath>

#define int64 long long int

using namespace std;

double round(double x){
	if(x > 0) return floor(x + 0.5);
	else return -1.0 * floor(fabs(x) + 0.5);
}

int main()
{
	int n;
	double x1,y1,x2,y2,x3,y3,x,y,r;
	double det,a1,b1,a2,b2,c1,c2;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		a1 = 2 * (x1 - x2), b1 = 2 * (y1 - y2);
		a2 = 2 * (x2 - x3), b2 = 2 * (y2 - y3);
		det = a1 * b2 - a2 * b1;
		c1 = (x1*x1 - x2*x2) + (y1*y1 - y2*y2);
		c2 = (x2*x2 - x3*x3) + (y2*y2 - y3*y3);
		x = (a1 * c1 + b1 * c2) / det;
		y = (a2 * c1 + b2 * c2) / det;
		r = sqrt((x - x1)*(x - x1) + (y - y1)*(y - y1));
		x = round(x * 1000) / 1000;
		y = round(y * 1000) / 1000;
		r = round(r * 1000) / 1000;
		printf("%.3f %.3f %.3f\n", x, y, r);
	}
	return 0;
}

C++: #include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
#include <complex>
  
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second
  
const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef complex<double> P;
int n;
  
double cross(P p1,P p2) {
    return (real(p1)*imag(p2) - imag(p1)*real(p2));
}
double calc_S(P p1,P p2,P p3) {
    double ret = 0.0;
    p1 -= p3;
    p2 -= p3;
  
    ret = cross(p1,p2)/2.0;
      
    return abs(ret);
}
  
int main() {
    cin>>n;
    while(n-->0) {
        double x1_,y1_;
        double x2_,y2_;
        double x3_,y3_;
        cin>>x1_>>y1_>>x2_>>y2_>>x3_>>y3_;
        P p1(x1_,y1_);
        P p2(x2_,y2_);
        P p3(x3_,y3_);
        P A = p1-p2;
        P B = p2-p3;
        P C = p1-p3;
        double S = calc_S(p1,p2,p3);
        double R = abs(A)*abs(B)*abs(C)/S;
        R /= 4.0;
          
        P A1 = 2.0*(p2-p1);
        P B1 = 2.0*(p3-p1);
        P C1 = P(norm(p1)-norm(p2),norm(p1)-norm(p3));
        double X = cross(P(imag(A1),imag(B1)),C1)/cross(A1,B1);
        double Y = cross(C1,P(real(A1),real(B1)))/cross(A1,B1);
        printf("%.3lf %.3lf %.3lf\n",X,Y,R);
  
    }
    return 0;
}