Go: package main

import (
	"fmt"
	"math"
)

func main() {
	n := scanInt()
	for i := 0; i < n; i++ {
		cal()
	}
}

func scanInt() int {
	var n int
	fmt.Scanf("%d", &n)
	return n
}

func cal() {
	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<string>
#include<sstream>
#include<cmath>
using namespace std;

double fpx(double a, double b, double c, double d, double e, double f);
double fpy(double a, double b, double c, double d, double e, double f);
double  fr(double a, double b, double c, double d);
string toStr(double a);
string intToString(int a);

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

  cin >> n;
  
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double px = fpx(x1, y1, x2, y2, x3, y3);
    double py = fpy(x1, y1, x2, y2, x3, y3);
    double  r =  fr(x1, y1, px, py);

    cout << toStr(px) << " " << toStr(py) << " " << toStr(r) << endl;
  }
}


double fpx(double x1, double y1, double x2, double y2, double x3, double y3) {
  double a1, a2, b1, b2, c1, c2;

  a1 = 2 * (x2 - x1);
  b1 = 2 * (y2 - y1);
  c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;

  a2 = 2 * (x3 - x1);
  b2 = 2 * (y3 - y1);
  c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;

  return (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
}

double fpy(double x1, double y1, double x2, double y2, double x3, double y3) {
  double a1, a2, b1, b2, c1, c2;

  a1 = 2 * (x2 - x1);
  b1 = 2 * (y2 - y1);
  c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;

  a2 = 2 * (x3 - x1);
  b2 = 2 * (y3 - y1);
  c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;

  return (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
}

double fr(double x1, double y1, double x2, double y2) {
  return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

string toStr(double d) {
  string pm = "", val = "";
  if (d < 0) {
    pm = "-";
    d = -d;
  }

  int ipart = (int)d;
  int fpart = (int)( (d - (double)ipart) * 10000) + 10005;

  val = pm + intToString(ipart) + "." + intToString(fpart).substr(1, 3);
  return val;
}

string intToString(int n) {
  stringstream ss;
  ss << n;
  return ss.str();
}

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

int main()
{
  double eps = 10e-7;
  double x1,y1,x2,y2,x3,y3;
  int T;
  scanf("%d",&T);
  for(int i=0;i<T;i++){
  scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
  double a = pow(x2-x3,2.0)+pow(y2-y3,2.0);
  double b = pow(x3-x1,2.0)+pow(y3-y1,2.0);
  double c = pow(x1-x2,2.0)+pow(y1-y2,2.0);
  double a2 = sqrt(pow(x2-x3,2.0)+pow(y2-y3,2.0));
  double b2 = sqrt(pow(x3-x1,2.0)+pow(y3-y1,2.0));
  double c2 = sqrt(pow(x1-x2,2.0)+pow(y1-y2,2.0));
  double s = (a2+b2+c2)/2.0;
  double S = sqrt(s*(s-a2)*(s-b2)*(s-c2));
  double px = (a*(b+c-a) * x1 + b*(c+a-b) * x2 + c*(a+b-c) * x3) / (16.0*pow(S,2.0));
  double py = (a*(b+c-a) * y1 + b*(c+a-b) * y2 + c*(a+b-c) * y3) / (16.0*pow(S,2.0));
  double r = a2*b2*c2/(4.0*S);
  px += 0.0005 + eps;
  py += 0.0005 + eps;
  r += 0.0005 + eps;
  printf("%.3f %.3f %.3f\n",px,py,r);
  }
}

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

class Point {
public:
  double x, y;
  Point(double x=0, double y=0) : x(x), y(y) {}
};

double dist(Point p1, Point p2) {
  return sqrt(pow(p1.x-p2.x, 2.0)+pow(p1.y-p2.y, 2.0));
}

Point circumcenter(Point pa, Point pb, Point pc) {
  double A = abs(atan2(pb.y-pa.y, pb.x-pa.x) - atan2(pc.y-pa.y, pc.x-pa.x));
  double B = abs(atan2(pa.y-pb.y, pa.x-pb.x) - atan2(pc.y-pb.y, pc.x-pb.x));
  double C = abs(atan2(pa.y-pc.y, pa.x-pc.x) - atan2(pb.y-pc.y, pb.x-pc.x));
  double a = dist(pb, pc);
  double b = dist(pa, pc);
  double c = dist(pa, pb);
  return Point((pa.x*sin(A*2)+pb.x*sin(B*2)+pc.x*sin(C*2))
	       /(sin(A*2)+sin(B*2)+sin(C*2)),
	       (pa.y*sin(A*2)+pb.y*sin(B*2)+pc.y*sin(C*2))
	       /(sin(A*2)+sin(B*2)+sin(C*2))
	       );
}

main() {
  Point p[3];
  Point op;
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < 3; j++) cin >> p[j].x >> p[j].y;
    op = circumcenter(p[0], p[1], p[2]);
    double A = abs(atan2(p[1].y-p[0].y, p[1].x-p[0].x)
		   - atan2(p[2].y-p[0].y, p[2].x-p[0].x));
    printf("%.3f %.3f %.3f\n", op.x, op.y, dist(p[1],p[2])/sin(A)/2.0);
  }
}

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

int main() {
	int n;
	std::cin >> n;
	double rax, ray, rbx, rby, rcx, rcy;
	for (int i = 0; i < n; i++) {
		double ax, ay, bx, by, cx, cy, aa, bb, cc, a, b, c, d, e, f, rx, ry, rr;
		std::cin >> rax >> ray >> rbx >> rby >> rcx >> rcy;
		ax = rbx - rax; ay = rby - ray;
		bx = rcx - rbx; by = rcy - rby;
		cx = rax - rcx; cy = ray - rcy;
		std::cerr << ax << " " << bx << " " << cx << std::endl;
		aa = ax * ax + ay * ay;
		bb = bx * bx + by * by;
		cc = cx * cx + cy * cy;
		std::cerr << aa << " " << bb << " " << cc << std::endl;
		a = std::sqrt(aa);
		b = std::sqrt(bb);
		c = std::sqrt(cc);
		std::cerr << a << " " << b << " " << c << std::endl;
		d = aa * (bb + cc - aa);
		e = bb * (cc + aa - bb);
		f = cc * (aa + bb - cc);
		std::cerr << d << " " << e << " " << f << std::endl;
		rx = ((d * rcx) + (e * rax) + (f * rbx)) / (d + e + f);
		ry = ((d * rcy) + (e * ray) + (f * rby)) / (d + e + f);
		rr = (a * b * c) / std::sqrt((a + b + c)*(-a + b + c)*(a - b + c)*(a + b - c));
		std::cout << std::fixed;
		std::cout << std::setprecision(3) << rx << " " << ry << " " << rr << std::endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#define double long double
using namespace std;

double marume( double x ){
	long long t = x * 1000 + ((x > 0) ? 1 : -1) * 0.5;
	return t/1000.0;
}

int main(){
	int n;
	double tx, ty, x1, y1, x2, y2;
	
	cin >> n;
	while(n--){
		cin >> tx >> ty >> x1 >> y1 >> x2 >> y2;
		x1 -= tx; y1 -= ty;
		x2 -= tx; y2 -= ty;
		
		double dist1 = x1 * x1 + y1 * y1;
		double dist2 = x2 * x2 + y2 * y2;
		x1 *= 2; y1 *= 2;
		x2 *= 2; y2 *= 2;
		
		double detA = x1 * y2 - y1 * x2;
		double detX = dist1 * y2 - y1 * dist2;
		double detY = x1 * dist2 - dist1 * x2;
		double x = detX / detA; //if(x < 0){ x -= 1e-5; } else { x += 1e-5; }
		double y = detY / detA; //if(y < 0){ y -= 1e-5; } else { y += 1e-5; }
		double r = hypot(x, y) + 1e-7;
		
		x += tx;
		y += ty;
		
		x = marume(x);
		y = marume(y);
		r = marume(r);
		printf("%.3Lf %.3Lf %.3Lf\n", x, y, r);
	}
	return 0;
}

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

int main(){
	
	int n;
	double x1,y1,x2,y2,x3,y3;
	
	cin>>n;
	while(n>0){
		double px,py,r;
		double A,B,C,a,b,c;
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		A=2*(x2-x1);
		B=2*(y2-y1);
		C=(pow(x1,2)-pow(x2,2))+(pow(y1,2)-pow(y2,2));
		a=2*(x3-x1);
		b=2*(y3-y1);
		c=(pow(x1,2)-pow(x3,2))+(pow(y1,2)-pow(y3,2));
		
		px=(B*c-b*C)/(A*b-a*B);
		py=(C*a-c*A)/(A*b-a*B);
		r=sqrt(pow(x1-px,2)+pow(y1-py,2));
				
		printf("%.3f %.3f %.3f\n",px,py,r);
		n--;
		
	}
}

C++: #include <iostream>
 #include <math.h>
 #include <string>
using namespace std;

int main() {
	int n;
	cin>>n;
	for(int h=0;h<n;h++){
double x1,y1,x2,y2,x3,y3,x2m,x3m,y2m,y3m,x21,y21,x31,y31,xy21,xans,yans;
cin>>x1>>y1>>x2>>y2>>x3>>y3;
	x2m=(x1+x2)/2;
	y2m=(y1+y2)/2;
	x3m=(x1+x3)/2;
	y3m=(y1+y3)/2;
	x21=x2-x1;
	x31=x3-x1;
	y21=y2-y1;
	y31=y3-y1;
	
	
if(y1!=y2){
	xy21=x21/y21;
	xans=(x31*x3m+y31*xy21*x2m+y3m-y2m)/(x31+y31*xy21);
	yans=xy21*(xans-x2m)+y2m;
}	
else{
	xans=x2m;
	yans=(x3m-xans)*x31/y31+y3m;
}
double r;
r=sqrt((xans-x1)*(xans-x1)+(yans-y1)*(yans-y1));
	printf("%.6f %.6f %.6f\n",xans,yans,r);
}

	return 0;
}