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>
#define _USE_MATH_DEFINES
#include <math.h>

int main(void){
	int n , i;
	float x1,x2,x3,y1,y2,y3,a1,a2,b1,b2,c1,c2,xp,yp,r;
	scanf("%d" , &n);
	for(i=1;i<=n;i++){
		scanf("%f %f %f %f %f %f" , &x1 , &y1 , &x2 , &y2 , &x3 , &y3);
		a1 = 2 * (x2 - x1);
		b1 = 2 * (y2 - y1);
		c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
		a2 = 2 * (x3 - y1);
		b2 = 2 * (y3 - y1);
		c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;
		xp = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
		yp = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
		r = sqrt((xp - x1) * (xp - x1) + (yp - y1) * (yp - y1));
		printf("%.3f %.3f %.3f\n" , xp+0.0 , yp+0.0 , r+0.0);
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double PI = acos(-1.0), EPS = 1e-10;

inline double SQ(double x) {
	return x * x;
}

inline double DIST(double x1, double y1, double x2, double y2) {
	return sqrt(SQ(x1 - x2) + SQ(y1 - y2));
}

int main() {
	int N; cin >> N;
	while(N--) {
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		double A = x1 - x2;
		double B = y1 - y2;
		double C = x1 - x3;
		double D = y1 - y3;
		
		double S = SQ(x1) - SQ(x2) + SQ(y1) - SQ(y2);
		double T = SQ(x1) - SQ(x3) + SQ(y1) - SQ(y3);
		
		double delta = (A * D - B * C);
		
		double X = (D * S - B * T) / 2 / delta;
		double Y = (-1 * C * S + A * T) / 2 / delta;
		
		printf("%.3f %.3f %.3f\n", X, Y, DIST(x1, y1, X, Y));
	}
	return 0;
}

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

//line is ax + by = c
struct Line{
  double a, b, c;
};

struct Node{
  double x, y;
};

Line perpendicular_bisector(Node a, Node b){
  Line result;
  result.a = a.x - b.x;
  result.b = a.y - b.y;
  result.c = (a.x * a.x - b.x * b.x + a.y * a.y - b.y * b.y) / 2;
  return result;
}

Node intersection(Line l, Line m){
  Node result;
  result.x = (m.b * l.c - l.b * m.c) / (l.a * m.b - m.a * l.b);
  result.y = (m.a * l.c - l.a * m.c) / (m.a * l.b - l.a * m.b);
  return result;
}

double distance(Node a, Node b){
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

void solve(){
  Node A, B, C;
  cin >> A.x >> A.y;
  cin >> B.x >> B.y;
  cin >> C.x >> C.y;
  Line l = perpendicular_bisector(A, B);
  Line m = perpendicular_bisector(A, C);
  Node center = intersection(l, m);
  double raidus = distance(center, A);
  printf("%.3lf %.3lf %.3lf", center.x, center.y, raidus);
}

int main(){
  int N;
  cin >> N;
  while(N--){
    solve();
  }
}

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

using namespace std;

int main() {
    
    int n;
    cin >> n;
    
    while (n--) {
        double x1, y1, x2, y2, x3, y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

        auto ab = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
        auto bc = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
        auto ca = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
        auto r = (ab * bc * ca) / sqrt((ab + bc + ca) * (-ab + bc + ca) * (ab - bc + ca) * (ab + bc - ca));

        auto a = 2 * (x2 - x1);
        auto b = 2 * (y2 - y1);
        auto c = (x2 - x1) * (x2 + x1) + (y2 - y1) * (y2 + y1);
        auto d = 2 * (x3 - x2);
        auto e = 2 * (y3 - y2);
        auto f = (x3 - x2) * (x3 + x2) + (y3 - y2) * (y3 + y2);
        
        auto px = (e * c - b * f) / (e * a - b * d);
        auto py = (d * c - a * f) / (d * b - a * e);

        printf("%.3f %.3f %.3f\n", floor(px * 1000 + 0.5) / 1000, floor(py * 1000 + 0.5) / 1000, floor(r * 1000 + 0.5) / 1000);
    }
    
    return 0;
}

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

int main(){
	int n;
	double x1,x2,x3,y1,y2,y3;
	double a1,a2,b1,b2,c1,c2;
	double px,py;

	cin >> n;
	while(n > 0){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		n--;
	}
	
	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;
	
	px = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
	py = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
	
	cout << fixed << setprecision(3) << px << fixed << setprecision(3) << py << fixed << setprecision(3) << hypot(px - x1, py - y1) << endl;

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main(){
  double x1,y1,x2,y2,x3,y3;
  vector<double> x1l,y1l,x2l,y2l,x3l,y3l;
  int n;

  cin >> n;

  for(int i=0; i<n; i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    x1l.push_back(x1);
    y1l.push_back(y1);
    x2l.push_back(x2);
    y2l.push_back(y2);
    x3l.push_back(x3);
    y3l.push_back(y3);
  }

  double ex,ey,fx,fy;
  double a,b,c,d,e,f,r;
  double cx,cy;

  for(int i=0; i<n; i++){
    x1=x1l[i];
    y1=y1l[i];
    x2=x2l[i];
    y2=y2l[i];
    x3=x3l[i];
    y3=y3l[i];

    a = x1*x1+y1+y1;
    b = x2*x2+y2+y2;
    c = x3*x3+y3+y3; 
    d = 0.5/(x1*y2-x2*y1+x2*y3-x3*y2+x3*y1-x1*y3);
    e = d*(a*y2-b*y1+b*y3-c*y2+c*y1-a*y3);
    f = d*(x1*b-x2*a+x2*c-x3*b+x3*a-x1*c);
    r = sqrt((e-x1)*(e-x1)+(f-y1)*(f-y1));
    printf("%0.3f %0.3f %0.3f\n",e,f,r);
  }

  return 0;
}

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;
		if(c2!=0.0) py = (c5-c6-c1*px)/c2;
		else py = (c5-c7-c3*px)/c4;
		double r = sqrt((px-x1)*(px-x1)+(py-y1)*(py-y1));
		cout << fixed << setprecision(3) << px << " " << py << " " << r << endl;
	}
}