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 <stdio.h>
#include <math.h>
using namespace std;

int main(){
	int a;
	scanf("%d",&a);
	while(a--){
		double x1,y1,x2,y2,x3,y3;
		scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
		double a1 = 2*(x2 - x1), b1 = 2*(y2 - y1);
		double c1 = x1*x1 - x2*x2 + y1*y1 - y2*y2;
		double a2 = 2*(x3-x1), b2 = 2*(y3-y1);
		double c2 = x1*x1 - x3*x3 + y1*y1 - y3*y3;
		double x = (b1*c2 - b2*c1)/(a1*b2 - a2*b1);
		double y = (c1*a2 - c2*a1)/(a1*b2 - a2*b1);
		double r = hypot(x-x1,y-y1);
		printf("%.3lf %.3lf %.3lf\n",x,y,r);
	}
}

C++: #include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	while( n-- > 0 ){
		double x[3], y[3];		// three points
		for( int i = 0; i < 3; i++ ){
			cin >> x[i] >> y[i];
		}
		double a[2];		// the slope of a line
		double b[2];		// the intersept of a line
		double ax, ay;
		int s = 0;
		for( int i = 0; i < 2; i++ ){
			if( y[i] == y[i+1] ){
				s = i+1;
			}else{
				a[i] = -(x[i] - x[i+1]) / (y[i] - y[i+1]);
				b[i] = (y[i] + y[i+1]) / 2.0 - a[i] * (x[i] + x[i+1]) / 2.0;
			}
		}
		if( a[0] == 0 ){
			ay = b[0];
			ax = ( ay - b[1] ) / a[1];
			if( s == 2){
				ax = ( x[1] + x[2] ) / 2;
				ay = a[0] * ax + b[0];
			}else if( s == 1 ){
				ax = ( x[0] + x[1] ) / 2;
				ay = a[1] * ax + b[1];
			}else{
				ax = ( b[1] - b[0] ) / ( a[0] - a[1] );
				ay = a[0] * ax + b[0];
			}
		}else if( a[1] == 0 ){
			ay = b[1];
			ax = ( ay - b[0] ) / a[0];
			if( s == 2){
				ax = ( x[1] + x[2] ) / 2;
				ay = a[0] * ax + b[0];
			}else if( s == 1 ){
				ax = ( x[0] + x[1] ) / 2;
				ay = a[1] * ax + b[1];
			}else{
				ax = ( b[1] - b[0] ) / ( a[0] - a[1] );
				ay = a[0] * ax + b[0];
			}
		}else{
			if( s == 2){
				ax = ( x[1] + x[2] ) / 2;
				ay = a[0] * ax + b[0];
			}else if( s == 1 ){
				ax = ( x[0] + x[1] ) / 2;
				ay = a[1] * ax + b[1];
			}else{
				ax = ( b[1] - b[0] ) / ( a[0] - a[1] );
				ay = a[0] * ax + b[0];
			}
		}
		double r = sqrt( pow( x[0] - ax, 2 ) + pow( y[0] - ay, 2 ) );
		printf("%.3f %.3f %.3f\n", ax, ay, r );
	}
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <sstream>
#include <string>
#include <cmath>

using namespace std;

const int EPS=1e-9;

namespace FP {
    bool isZero(double x) {
        return (abs(x) <= EPS);
    }
};

struct Point {
    double x, y;
    Point(double x=0, double y=0) : x(x), y(y) {}
    string to_s() {
        ostringstream os;
        os << "(" << x << "," << y << ")";
        return os.str();
    }
    bool operator<(const Point &o) const {
        return x == o.x ? y < o.y : x < o.x;
    }
    Point operator+(const Point &o) const {
        return Point(x+o.x, y+o.y);
    }
    Point operator-(const Point &o) const {
        return Point(x-o.x, y-o.y);
    }
    Point operator*(const double m) const {
        return Point(x*m, y*m);
    }
    Point operator/(const double d) const {
        return Point(x/d, y/d);
    }
    // 外積
    double cross(const Point &o) const {
        return x * o.y - y * o.x;
    }
    // 内積
    double dot(const Point &o) const {
        return x * o.x + y * o.y;
    }
    // ベクトルがx軸となす角
    double atan() const {
        return atan2(y, x);
    }
    // ベクトルの長さの二乗
    double norm() const {
        return dot(*this);
    }
};

struct Line {
    double a, b, c;
    Line(double a=0, double b=0, double c=0) :
        a(a), b(b), c(c) {}
    Point intersectionPoint(const Line &l) const {
        double d = a * l.b - l.a * b;
        if (!intersects(l)) {
            throw string("The 2 Lines are parallel");
        }
        double x = (b * l.c - l.b * c) / d;
        double y = (l.a * c - a * l.c) / d;
        return Point(x, y);
    }
    bool intersects(const Line &l) const {
        return !FP::isZero(a * l.b - l.a * b);
    }
    string to_s() {
        ostringstream os;
        os << a << ' ' << b << ' ' << c;
        return os.str();
    }
    static Line fromPoints(const Point &a, const Point &b) {
        double dx = b.x - a.x;
        double dy = b.y - a.y;
        return Line(dy, -dx, dx * a.y - dy * a.x);
    }
    static Line fromPoints(double x1, double y1, double x2, double y2) {
        return fromPoints(Point(x1, y1), Point(x2, y2));
    }
};

struct LineSegment {
    Point start, end;
    LineSegment(const Point &start, const Point &end) : start(start), end(end) {}
    LineSegment(double x1, double y1, double x2, double y2) : start(Point(x1, y1)), end(Point(x2, y2)) {}
    string to_s() {
        ostringstream os;
        os << '(' << start.x << ',' << start.y << ')' << '-' << '(' << end.x << ',' << end.y << ')' << endl;
        return os.str();
    }
    Line toLine() const {
        return Line::fromPoints(start, end);
    }
    bool intersects(const Line &l) const {
        double t1 = l.a * start.x + l.b * start.y + l.c;
        double t2 = l.a * end.x + l.b * end.y + l.c;
        return t1 * t2 <= 0;
    }
    bool intersects(const LineSegment &s) const {
        return intersects(s.toLine()) && s.intersects(toLine());
    }
    Line perpendicularBisector() const {
        Point p1 = (start + end) / 2;
        Point p2;
        p2.x = -(end - p1).y;
        p2.y = (end - p1).x;
        p2 = p2 + p1;
        return Line::fromPoints(p1, p2);
    }
};

int main() {
    int n; cin >> n;
    Point p[3];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) cin >> p[j].x;
        for (int j = 0; j < 3; j++) cin >> p[j].y;
        LineSegment a(p[0], p[1]);
        LineSegment b(p[0], p[2]);
        Point c = a.perpendicularBisector().intersectionPoint(b.perpendicularBisector());
        double r = sqrt((p[0] - c).norm());
        cout << fixed << setprecision(3);
        cout << c.x << ' ' << c.y << ' ' << r << endl;
    }

    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;
}