Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var num int
	fmt.Scan(&num)
	for i := 0; i < num; i++ {
		var x1, y1, x2, y2, x3, y3 float64
		fmt.Scanf("%f%f%f%f%f%f", &x1, &y1, &x2, &y2, &x3, &y3)

		a := 2 * (x2 - x1)
		b := 2 * (y2 - y1)
		c := 2 * (x3 - x1)
		d := 2 * (y3 - y1)
		e := x2*x2 - x1*x1 + y2*y2 - y1*y1
		f := x3*x3 - x1*x1 + y3*y3 - y1*y1

		// 直線1: ax + by - e = 0
		// 直線2: cx + dy - f = 0
		px := (d*e - b*f) / (a*d - b*c)
		py := (c*e - a*f) / (b*c - a*d)
		r := math.Sqrt((px-x1)*(px-x1) + (py-y1)*(py-y1))
		fmt.Printf("%.3f %.3f %.3f\n", px, py, r)
	}
}

C++: #include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		double x1,x2,x3,y1,y2,y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double c1 = 2.0*(x1-x2);
		double c2 = 2.0*(y1-y2);
		double c3 = 2.0*(x1-x3);
		double c4 = 2.0*(y1-y3);
		double c5 = x1*x1 + y1*y1;
		double c6 = x2*x2 + y2*y2;
		double c7 = x3*x3 + y3*y3;
		double px = (c4*(c5-c6)-c2*(c5-c7))/(c1*c4-c2*c3);
		double py = (c5-c6-c1*px)/c2;
		double r = sqrt((px-x1)*(px-x1)+(py-y1)*(py-y1));
		cout << fixed << setprecision(3) << px << " " << py << " " << r << endl;
	}
}

C++: #include <iostream>
#include <stdio.h>
#include <math.h>
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 a,b,c,sin2a,sin2b,sin2c,px,py,r;
		a = (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3);
		b = (x3-x1)*(x3-x1) + (y3-y1)*(y3-y1);
		c = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
		sin2a = a*(-a+b+c);
		sin2b = b*(a-b+c);
		sin2c = c*(a+b-c);
		px = (x1*sin2a + x2*sin2b + x3*sin2c) / (sin2a + sin2b + sin2c);
		py = (y1*sin2a + y2*sin2b +y3*sin2c) / (sin2a + sin2b + sin2c);
		double ra,rb,rc;
		ra = sqrt(a);
		rb = sqrt(b);
		rc = sqrt(c);
		r = sqrt(a*b*c/((ra+rb+rc)*(-ra+rb+rc)*(ra-rb+rc)*(ra+rb-rc)));
		printf("%.3f %.3f %.3f\n",px,py,r);
	}
	return 0;
}

C++: #define INF 100000000
using namespace std;
#define pw(a) (a)*(a)

int main(){
  double x1,x2,x3,y1,y2,y3;
  int n;
  cin >> n;
  while(n--){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double a,b,l,m,n;
    a = -1*(pw(x1) - pw(x2) + pw(y1) - pw(y2));
    b = -1*(pw(x1) - pw(x3) + pw(y1) - pw(y3));
    l = (a*(y1-y3)+b*(y1-y2))/((y1-y3)*(x1-x2)-(x1-x3)*(y1-y2));
    m = (b-(x1-x3)*l)/(y1-y3);
    n = (x1*l + y1*m) - (pw(x1) + pw(y1));
    printf("%.3f %.3f %.3f\n",(float)-l/2,(float)-m/2,(float)sqrt((pw(l) + pw(m) - 4*n))/2);
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define REP0(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
const double eps=1e-9;
struct seg{double a,b,c;};
seg calc(double x1,double y1,double x2,double y2){
	double a=y1-y2,b=x2-x1,c=x2*y1-x1*y2;
	seg ret;
	ret.a=a;
	ret.b=b;
	ret.c=c;
	return ret;
}
int main(){
	int n;
	scanf("%d",&n);
	REP0(i,n){
		double x1,y1,x2,y2,x3,y3,ox,oy;
		scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
		seg k=calc(x1,y1,x2,y2);
		seg l=calc(x1,y1,x3,y3);
		double mx1=(x1+x2)/2,my1=(y1+y2)/2,mx2=(x1+x3)/2,my2=(y1+y3)/2;
		seg s1,s2;
		s1.a=k.b;
		s1.b=-k.a;
		s1.c=s1.a*mx1+s1.b*my1;
		s2.a=l.b;
		s2.b=-l.a;
		s2.c=s2.a*mx2+s2.b*my2;
		ox=(s1.c*s2.b-s2.c*s1.b)/(s1.a*s2.b-s2.a*s1.b);
		oy=(s1.a*s2.c-s2.a*s1.c)/(s1.a*s2.b-s2.a*s1.b);
		printf("%.3lf %.3lf %.3lf\n",ox+eps,oy+eps,sqrt((x1-ox)*(x1-ox)+(y1-oy)*(y1-oy))+eps);
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <cmath>
using namespace std;
typedef complex<double> P;

const double eps = 1e-5;
vector<P> ps(3);
double R;

double eval(P p) {
  double sum = 0;
  for(int i = 0; i < ps.size(); ++i)
    sum += abs(R-abs(p-ps[i]));
  return sum;
}

P getBestP(P o, double r) {
  double s = 200;
  double mini = 1e100;
  P bestP;
  double begin = -r;
  double end = r;
  for(int i = 0; i < s; ++i) {
    for(int j = 0; j < s; ++j) {
      P v(begin + j/s*(end-begin), begin + i/s*(end-begin));
      P p = o+v;
      double tmp = eval(p);
      if(tmp < mini) {
	mini = tmp;
	bestP = p;
      }
    }
  }
  return bestP;
}

int main() {
  int Tc;
  cin >> Tc;
  for(int tc = 0; tc < Tc; ++tc) {
    for(int i = 0; i < ps.size(); ++i) cin >> ps[i].real() >> ps[i].imag();
    R = abs(ps[1]-ps[2])/abs(sin(arg(ps[1]-ps[0])-arg(ps[2]-ps[0])))/2.0;
    P res(0,0);
    for(double r = 100.0; r > eps; r *= 0.1) {
      res = getBestP(res, r);
    }
    printf("%.3f %.3f %.3f\n", res.real(), res.imag(), R);
  }
  return 0;
}

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

void gradcut(double *a,double *b,double x1,double y1,double x2,double y2);

int main() {
    double x[3],y[3],a[2],b[2],rx,ry,r;
    int n;
    std::cin >> n;
    for(int j=0;j<n;j++){
        int am=0,add=1;;
        for(int i=0;i<3;i++) std::cin >> x[i] >> y[i];
        for(int i=0;i<3;i++){
            if(i==2) add=-2;
            if(x[i]!=x[i+add]&&y[i]!=y[i+add]){
                gradcut(&a[am],&b[am],x[i],x[i+add],y[i],y[i+add]);
                am++;
                if(am>2) break;
            }else if(x[i]==x[i+add]){
                a[am]=0;
                b[am]=(y[i]+y[i+add])/2;
                am++;
                if(am>2) break;
            }
        }


        rx = (b[1]-b[0])/(a[0]-a[1]);
        ry = a[0]*rx+b[0];
        r=sqrt((x[0]-rx)*(x[0]-rx)+(y[0]-ry)*(y[0]-ry));
        printf("%.3f %.3f %.3f\n",rx,ry,r);
    }
    return 0;
}

void gradcut(double *a,double *b,double x1,double x2,double y1,double y2){
    *a=-(x2-x1)/(y2-y1);
    *b=(y1+y2)/2-(*a)*(x1+x2)/2;
}

C++: #include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


using P = complex<long double>;

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  for (int _ = 0; _ < n; ++_) {
    V<P> p(3);
    for (int i = 0; i < 3; ++i) {
      long double x, y; cin >> x >> y;
      p[i] = {x, y};
    }
    P numer = 0;
    for (int i = 0; i < 3; ++i) {
      numer += p[i] * (norm(p[(i + 2) % 3]) - norm(p[(i + 1) % 3]));
    }
    P denom = 0;
    for (int i = 0; i < 3; ++i) {
      denom += p[i] * conj(p[(i + 2) % 3] - p[(i + 1) % 3]);
    }
    P r = numer / denom;
    cout << fixed << setprecision(3) << real(r) << ' ' << imag(r) << ' ' << abs(p[0] - r) << '\n';
  }
}

C++: #include<cstdio>
#include<cmath>
using namespace std;
double x1,Y1,x2,y2,x3,y3;
double px, py,r;
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lf%lf%lf%lf%lf%lf",&x1,&Y1,&x2,&y2,&x3,&y3);
        double A1 =(x2*x2+y2*y2-x1*x1-Y1*Y1)*(y3-Y1);
        double B1 =(x3*x3+y3*y3-x1*x1-Y1*Y1)*(y2-Y1);
        double A2 =(x3*x3+y3*y3-x1*x1-Y1*Y1)*(x2-x1);
        double B2 =(x2*x2+y2*y2-x1*x1-Y1*Y1)*(x3-x1);
        double D = (x2-x1)*(y3-Y1)-(y2-Y1)*(x3-x1);
         px=(A1-B1)/D/2;
         py=(A2-B2)/D/2;
         r = sqrt((px-x1)*(px-x1)+(py-Y1)*(py-Y1));
        printf("%.3f %.3f %.3f\n",px,py,r);
    }
    return 0;
}