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 <math.h>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <cstdio>
#include <string.h>
using namespace std;

#define FOR(i, n) for(int i = 0; i < n; i++)
#define bit(i) static_cast<bitset<8> >(i)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long>PLL;
typedef queue<int> QI;
typedef priority_queue<int> maxpq;
typedef priority_queue<int, vector<int>, greater<int> > minpq;

struct edge{int to, cost;};

void begin(){cin.tie(0); ios::sync_with_stdio(false);};
int gcd(int a, int b){if(a%b==0){return(b);}else{return(gcd(b,a%b));}};
int lcm(int m, int n){if((0 == m)||(0 == n)){return 0;} return ((m / gcd(m, n)) * n);};
unsigned long long comb(long n, long m){unsigned long long c = 1; m = (n - m < m ? n - m : m);
    for(long ns = n - m + 1, ms = 1; ms <= m; ns ++, ms ++){c *= ns; c /= ms;} return c;};

void cp(int a1[], int a2[], int l){FOR(i, l) a2[i] = a1[i];};
double sq(double d){return d*d;};
int sq(int i){return i*i;};
double sqdist(int x1, int y1, int x2, int y2){
    double dx = x1 - x2, dy = y1 - y2; return dx*dx + dy*dy;
};

// ワーシャルフロイド法
void warshallFloyd(int d[100][100], int n){
    for(int k = 0; k < n; ++k)
        for(int i = 0; i < n; ++i)
            for(int j = 0; j < n; ++j)
                if(d[i][k] != -1 && d[k][j] != -1){
                    if(d[i][j] == -1){
                        d[i][j] = d[i][k] + d[k][j];
                    }else{
                        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                    }
                }
};


// d:隣接行列  n:グラフのサイズ  s:始点  dist:始点からの距離が入る配列
void dijkstra(int d[1000][1000], int n, int s, int dist[1000]){
    FOR(i, n) dist[i] = -1;
    dist[s] = 0;
    priority_queue<PII, vector<PII>, greater<PII> > q;
    q.push(PII(0, s));
    while (!q.empty()) {
        PII p = q.top(); q.pop();
        int i = p.second;
        if(dist[i] < p.first) continue;
        for(int j = 0; j < n; j++){
            if(d[i][j] == -1) continue;
            if(dist[j] == -1){
                dist[j] = dist[i] + d[i][j];
                q.push(PII(dist[j], j));
            }else if(dist[j] > dist[i] + d[i][j]){
                dist[j] = dist[i] + d[i][j];
                q.push(PII(dist[j], j));
            }
        }
    }
};

// 線分の交差判定
bool isCross(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4){
    // 並行な場合
    int m = (x2-x1)*(y4-y3)-(y2-y1)*(x4-x3);
    if(m == 0) return false;
    // 媒介変数の値が0より大きく1以下なら交差する、これは問題の状況によって変わるかも。
    double r =(double)((y4-y3)*(x3-x1)-(x4-x3)*(y3-y1))/m;
    double s =(double)((y2-y1)*(x3-x1)-(x2-x1)*(y3-y1))/m;
    return (0 < r && r <= 1 && 0 < s && s <= 1);
};

// 外積の計算 AB CD の内積を求める
int crossProdct(int ax, int ay, int bx, int by, int cx, int cy, int dx, int dy){
    int abx = bx - ax; int aby = by - ay;
    int cdx = dx - cx; int cdy = dy - cy;
    return abx * cdy - cdx * aby;
};
double crossProdct(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy){
    double abx = bx - ax; double aby = by - ay;
    double cdx = dx - cx; double cdy = dy - cy;
    return abx * cdy - cdx * aby;
};
double innerProduct(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy){
    double abx = bx - ax; double aby = by - ay;
    double cdx = dx - cx; double cdy = dy - cy;
    return abx * cdx + aby * cdy;
};

// 三角形の内部判定 ABCの中にPがあるか判定
bool inTriangle(int ax, int ay, int bx, int by, int cx, int cy, int px, int py){
    int c1 = crossProdct(ax, ay, bx, by, bx, by, px, py);
    int c2 = crossProdct(bx, by, cx, cy, cx, cy, px, py);
    int c3 = crossProdct(cx, cy, ax, ay, ax, ay, px, py);
    return (c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0);
};
bool inTriangle(double ax, double ay, double bx, double by, double cx, double cy, double px, double py){
    double c1 = crossProdct(ax, ay, bx, by, bx, by, px, py);
    double c2 = crossProdct(bx, by, cx, cy, cx, cy, px, py);
    double c3 = crossProdct(cx, cy, ax, ay, ax, ay, px, py);
    return (c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0);
};

// 三角形の外心
void circumcenter(double ax, double ay, double bx, double by, double cx, double cy, double res[3]){
    // AB AC を求める
    double abx = bx - ax; double aby = by - ay;
    double acx = cx - ax; double acy = cy - ay;
    double m = abx * acy - acx * aby; // 分母 m = 0 となるのは3点が一直線になるとき
    double s = (abx * acx + aby * acy - sq(acx) - sq(acy)) / m; // 媒介変数s
    res[0] = abx / 2 + s * aby / 2; res[1] = aby / 2 - s * abx / 2;
    res[2] = sqrt(sqdist(0, 0, res[0], res[1]));
    res[0] += ax; res[1] += ay;
};




/**
 * start
 * @author yoshikyoto
 */
int main(int argc, const char * argv[]){
    begin();
    int n;
    cin >> n;
    FOR(i, n){
        double x1, y1, x2, y2, x3, y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        double res[3];
        circumcenter(x1, y1, x2, y2, x3, y3, res);
        printf("%.3lf %.3lf %.3lf", res[0], res[1], res[2]);
    }
}

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

float a, b, c, d, e, f;
float x, y;

void solve(){
  float tmp1 = f-(c*d/a);
  float tmp2 = e-(b*d/a);
  y = tmp1/tmp2;
  x = (c - b * y) / a;
  printf("%.3f %.3f ", x, y);        
  //printf("y=%f\n", (f-(c*d/a))/(e-(b*d/a)));
}

int main(int argc, char const* argv[]) {
  int n;
  cin>>n;
  for (int i = 0; i < n; i += 1) {
    float x1, y1, x2, y2, x3, y3;
    cin>>x1>>y1>>x2>>y2>>x3>>y3;
    a = -2*x1 + 2*x2;
    b = -2*y1 + 2*y2;
    c = x2*x2 + y2*y2 - x1*x1 - y1*y1;
    d = -2*x1 + 2*x3;
    e = -2*y1 + 2*y3;
    f = x3*x3 + y3*y3 - x1*x1 - y1*y1;
    solve();
    float r = (x - x1)*(x - x1) + (y - y1)*(y - y1);
    printf("%.3f\n", sqrt(r));
  }  
  return 0;
}

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

using namespace std;

int n;
double a, b, c, d, e, f;
double x[3], y[3];
double r;
double px, py;

int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];

		a = x[0] - x[1];
		b = y[0] - y[1];
		c = (x[1]*x[1] - x[0]*x[0] + y[1]*y[1] - y[0]*y[0]) / 2;
		d = x[2] - x[0];
		e = y[2] - y[0];
		f = (x[0]*x[0] - x[2]*x[2] + y[0]*y[0] - y[2]*y[2]) / 2;

		px = -(c * e - f * b) / (a * e - d * b);
		py = -(c * d - f * a) / (b * d - e * a);
		r = sqrt((x[0] - px) * (x[0] - px) + (y[0] - py) * (y[0] - py));

		printf("%.3f %.3f %.3f\n", px, py, r);
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

C++: #include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
main(){
	int data;
	cin>>data;
	for(int r=1;r<=data;++r){
		double x1,x2,x3,y1,y2,y3,d,x,y,r;
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		d=4*(x3-x2)*(y2-y1)-4*(y3-y2)*(x2-x1);
		x=2*(x3*x3-x2*x2+y3*y3-y2*y2)*(y2-y1)-2*(y3-y2)*(x2*x2-x1*x1+y2*y2-y1*y1);
		y=2*(x3-x2)*(x2*x2-x1*x1+y2*y2-y1*y1)-2*(x3*x3-x2*x2+y3*y3-y2*y2)*(x2-x1);
		x2=x/d;
		y2=y/d;
		r=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
		printf("%.3f %.3f %.3f\n",x2,y2,r);
	}
}