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 <cstdio>
#include <cassert>
#include <cmath>
#include <complex>
#include <vector>
#include <utility>
using namespace std;

typedef complex<double> Point;
#define X real()
#define Y imag()
#define EPS 10e-8

namespace std {
  bool operator < (Point a, Point b) {
    if (a.X != b.X) return a.X < b.X;
    return a.Y < b.Y;
  }
}

double cross(Point a, Point b) {
  return (conj(a)*b).Y;
}

double dot(Point a, Point b) {
  return (conj(a)*b).X;
}

double dist2(Point a, Point b) {
  return dot(a-b, a-b);
}

struct Line : public vector<Point> {
  Line(Point a, Point b) {push_back(a); push_back(b);}
};

int n;
Point ps[3];

Line PerpendBisect(Line l) {
  Point mid = (l[0]+l[1])/2.0;
  return Line(mid, mid+(l[1]-l[0])*Point(0, 1));
}

Point GetCrossPoint(Line l, Line m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0];
  if (abs(A) < EPS) assert(false);
  return m[0] + B / A * (m[1]-m[0]);
}

double round3(double t) {
  return round(t*1000)/1000.0;
}

int main() {
  scanf("%d", &n);
  while (n--) {
    for (int i=0; i<3; i++) {
      double x, y;
      scanf("%lf%lf", &x, &y);
      ps[i] = Point(x, y);
    }

    Line l(ps[0], ps[1]);
    Line m(ps[1], ps[2]);
    Point p = GetCrossPoint(PerpendBisect(l), PerpendBisect(m));
    double r = sqrt(dist2(p, ps[0]));
    printf("%.3f %.3f %.3f\n", round3(p.X), round3(p.Y), round3(r));
  }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long int ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

void se(double a, double b, double c, double d, double e, double f,double *x,double *y){
	if (a < 0){
		a = -a;
		b = -b;
		c = -c;
	}
	if (b == -0)b = 0;
	if (d < 0){
		d = -d;
		e = -e;
		f = -f;
	}
	cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << "\n";
	if (a == 0){
		*y = c / b;
		*x = (f - e*(*y)) / d;
	}
	else if (b == 0){
		*x = c / a;
		*y = (f - e*(*x)) / d;
	}
	if (d == 0){
		*y = f / e;
		*x = (c - b*(*y)) / a;
	}
	else if (e == 0){
		*x = f / d;
		*y = (c - a*(*x)) / b;
	}
	else if (a != 0 && b != 0 && d != 0 && e != 0){
		*x = (b*f - c*e) / (b*d - a*e);
		*y = (c*d - a*f) / (b*d - a*e);
	}
}


int main(){
	double x1, y1, x2, y2, x3, y3, px, py, r;
	ll n;
	cin >> n;
	REP(i,n){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		se(2.0*(x1 - x2), 2.0*(y1 - y2),
			pow(x1, 2.0) + pow(y1, 2.0) - pow(x2, 2.0) - pow(y2, 2.0),
			2.0*(x2 - x3), 2.0*(y2 - y3),
			pow(x2, 2.0) + pow(y2, 2.0) - pow(x3, 2.0) - pow(y3, 2.0), &px, &py);
		r = pow(pow(x1 - px, 2.0) + pow(y1 - py, 2.0), 0.5);

		printf("%.3lf %.3lf %.3lf", px, py, r);
	}
}

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

int main(){
    int n;
    double x1, x2, x3, y1, y2, y3, x, y;
    cin >> n;
    for(int i = 0;i < n;i++){
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
	if(y1 == y2)swap(x1, x3), swap(y1, y3);
	else if(y1 == y3)swap(x1, x2), swap(y1, y2);
	double x = (x3-x1)/(y1-y3)*(x1+x3)/2-(x2-x1)/(y1-y2)*(x1+x2)/2-(y1+y2)/2+(y1+y3)/2;
	x /= ((x3-x1)/(y1-y3) - (x2-x1)/(y1-y2));
	double y = (x2-x1)/(y1-y2)*(x - (x1+x2)/2) + (y1+y2)/2;
	cout << x << " " << y << " " << hypot(x1-x,y1-y) << endl;   
    }
    return 0;
}
/*
x1y1 x2y2
y = (x2-x1)/(y1-y2)*(x - x1+x2/2) + y1+y2/2
y = (x3-x1)/(y1-y3)*(x - x1+x3/2) + y1+y3/2


(x3-x1)/(y1-y3)*(x - x1+x3/2) + y1+y3/2
 = (x2-x1)/(y1-y2)*(x - x1+x2/2) + y1+y2/2
((x3-x1)/(y1-y3) - (x2-x1)/(y1-y2))*x
=
(x3-x1)/(y1-y3)*(x1+x3)/2-(x2-x1)/(y1-y2)*(x1+x2)/2+(y1+y2)/2-(y1+y3)/2

*/

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

int main() {
	int sampleNum;
	scanf("%d", &sampleNum);
	for (; sampleNum > 0; --sampleNum) {
		double x1, y1, x2, y2, x3, y3;
		scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);

		double ax = x3 - x2;
		double ay = y3 - y2;
		double a2 = ax * ax + ay * ay;
		double a = sqrt(a2);
		double bx = x1 - x3;
		double by = y1 - y3;
		double b2 = bx * bx + by * by;
		double b = sqrt(b2);
		double cx = x2 - x1;
		double cy = y2 - y1;
		double c2 = cx * cx + cy * cy;
		double c = sqrt(c2);

		double crossabz = ax * by - ay * bx;

		double px, py, r;

		if (crossabz == 0) {
			if (a < b) {
				if (b < c) {
					px = (x1 + x2) / 2.;
					py = (y1 + y2) / 2.;
					r = c / 2.;
				} else {
					px = (x3 + x1) / 2.;
					py = (y3 + y1) / 2.;
					r = b / 2.;
				}
			} else {
				px = (x2 + x3) / 2.;
				py = (y2 + y3) / 2.;
				r = a / 2.;
			}
		} else {
			double bunbo = a2 * a2 - 2. * a2 * (b2 + c2) + (b2 - c2) * (b2 - c2);
			double keisu1 = a2 * (a2 - b2 - c2);
			double keisu2 = b2 * (b2 - c2 - a2);
			double keisu3 = c2 * (c2 - a2 - b2);
			px = (keisu1 * x1 + keisu2 * x2 + keisu3 * x3) / bunbo;
			py = (keisu1 * y1 + keisu2 * y2 + keisu3 * y3) / bunbo;

			double s = fabs(crossabz) / 2.;
			r = a * b * c / (4. * s);
		}

		if ( px <= 0. && px > 5.e-4 ) { px = 0.; }
		if ( py <= 0. && py > 5.e-4 ) { py = 0.; }

		printf("%.3lf %.3lf %.3lf\n", px, py, r);
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define EPS (1e-5)
#define equals(a, b) (fabs(a - b) < EPS)

struct Point {
    double x, y;

    Point(){}
    Point(double x, double y) : x(x), y(y) {}

    Point operator + (const Point &p) const {
        return Point(x + p.x, y + p.y);
    }

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

double dot(const Point &a, const Point &b)
{
    return a.x * b.x + a.y * b.y;
}

double norm(const Point &p)
{
    return dot(p, p);
} 

double abs(const Point &p)
{
    return sqrt(norm(p));
}

typedef vector<Point> Polygon;

struct Circle {
    Point p;
    double r;
    Circle(Point p, double r) : p(p), r(r) {}
};

bool check(const Polygon &pg, const Point &p)
{
    double r = abs(pg[0] - p);
    for (int i = 1; i < 3; i++) {
        if (!equals(r, abs(pg[i] - p))) return 0;
    }
    return 1;
}

Circle smallest_enclosing_circle(const Polygon &pg)
{    
    Point p(0, 0);
    int N = 3;
    for (int i = 0; i < (int)pg.size(); i++) {
	p = p + pg[i];
    }
    p = p * (1. / pg.size());
    double d = 0.5;
    while (!check(pg, p)) {
	for (int i = 0; i < 150; i++) {
	    int s = 0;
	    for (int j = 0; j < N; j++) {
		if (abs(pg[s] - p) - abs(pg[j] - p) < -EPS) {
		    s = j;
		}
	    }
	    p = p + (pg[s] - p) * d;
	}
	d *= 0.5;
    }
    double r = abs(p - pg[0]);
    return Circle(p, r);
}

int main()
{
    Polygon pg(3);
    int N;
    cin >> N;
    while (N--) {
        for (int i = 0; i < 3; i++) {
            cin >> pg[i].x >> pg[i].y;
        }
        auto c = smallest_enclosing_circle(pg);
        printf("%.3f %.3f %.3f\n", c.p.x, c.p.y, c.r);
    }
    return 0;
}