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 <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>
#include <map>
#include <math.h>
#include <utility>


#pragma warning(disable:4996)
using namespace std;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;
const double PI = 3.141592653589793238;
const Int INF = 999999999999;
typedef pair<int, int> P;


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

		double x21 = x2 - x1;
		double x31 = x3 - x1;
		double y21 = y2 - y1;
		double y31 = y3 - y1;

		double xc = ((y31*(x21*x21 + y21*y21)) - (y21*(x31*x31 + y31*y31))) /
			(2 * (x21*y31 - y21*x31));

		double yc = ((x21*(x31*x31 + y31*y31)) - (x31*(x21*x21 + y21*y21))) /
			(2 * (x21*y31 - y21*x31));	
		
		double d = (xc - x1)*(xc - x1) + (yc - y1)*(yc - y1);
		d = sqrt(d);
		/*
		if (xc < 0){
			xc *= 1000;
			xc -= 0.5;
			floor(xc);
			xc /= 1000;
		}

		if (yc < 0){
			yc *= 1000;
			yc -= 0.5;
			floor(yc);
			yc /= 1000;
		}
		*/
		printf("%.3lf %.3lf %.3lf\n", xc, yc, d);
	}

}

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

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

    scanf("%lf", &n);
    for(int i = 0; i < n; i++){
        scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);

        // (x-a)^2+(y-b)^2=r^2$KFM$C9~$`$+?

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

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

        px = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
        py = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
        r = sqrt( pow((px - x1),2) + pow((py - y1),2) );
        printf("%.3f %.3f %.3f\n", px, py, r);
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
class Point{
	public:
	double x,y;
	void input(){
		cin>>x>>y;
	}
};
double dist(Point a,Point b){
	return sqrt(pow(a.x-b.x,2.0)+pow(a.y-b.y,2.0));
}
class Line{
	public:
	double a,b,c;//ax+by=c
	Line(Point s,Point t){
		//x=(x1+x2)/2 , y=(y1+y2)/2????????????
		//??????a=-(x1-x2)/(y1-y2)?????´???
		//(y1-y2)(y-(y1+y2)/2) = -(x1-x2)(x-(x1+x2)/2)
		//(x1-x2)x + (y1-y2)y = (x1^2-x2^2)/2 + (y1^2-y2^2)/2
		a=s.x-t.x;	b=s.y-t.y;
		c=((s.x+t.x)*(s.x-t.x)+(s.y+t.y)*(s.y-t.y))/2.0;
	}
	void multi(double x){
		a*=x;	b*=x;	c*=x;
	}
};
double searchx(Line s,Line t){
	double tmp=s.b;
	s.multi(t.b);	t.multi(tmp);
	return (s.c-t.c)/(s.a-t.a);
}
double searchy(Line s,Line t){
	double tmp=s.a;
	s.multi(t.a);	t.multi(tmp);
	return (s.c-t.c)/(s.b-t.b);
}
int main(){
	int n;	cin>>n;
	while(n--){
		Point a,b,c;
		a.input();	b.input();	c.input();
		Line l(a,b),m(b,c);
		Point center;
		center.x=searchx(l,m);	center.y=searchy(l,m);
		double dis=dist(center,a);
		printf("%.3lf %.3lf %.3lf\n",center.x,center.y,dis);
	}
	return 0;
}

C++: #include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

int main()
{
  int N;
  cin >>N;
  double x1,y1,x2,y2,x3,y3;
  for(int i = 0;i < N;i++){
    cin >>x1>>y1>>x2>>y2>>x3>>y3;
    double a =(x1-x2);
    double b =(y1-y2);
    double c = -(pow(x1,2)+pow(y1,2))+(pow(x2,2)+pow(y2,2));
    double d =(x2-x3);
    double e =(y2-y3);
    double f =-(pow(x2,2)+pow(y2,2))+(pow(x3,2)+pow(y3,2));
    double l =(c*e-f*b)/(a*e-d*b);
    double m =(c*d-a*f)/(b*d-a*e);
    double n =-(pow(x1,2)+pow(y1,2))-(l*x1+m*y1);
    double x = -l/2;
    x +=0.0005;
    x =x*1000;
    x =(int)x;
    x =x/1000;
    double y =-m/2;
    y +=0.0005;
    y =y*1000;
    y =(int)y;
    y =y/1000;
    double r =sqrt(pow(l,2)+pow(m,2)-4*n)/2;
    r +=0.0005;
    r =r*1000;
    r =(int)r;
    r =r/1000;
    printf("%.3f %.3f %.3f\n",x,y,r);
  }
  
  return 0;
}

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

void crpt(double a1, double b1, double c1, double a2, double b2, 
	double c2, double *x, double *y) {

	*x = (b2 * c1 - b1 * c2) / (a1 * b2 - a2 * b1);
	*y = (a1 * c2 - a2 * c1) / (a1 * b2 - a2 * b1);
}

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, py, r;

		crpt(x2 - x1, y2 - y1, (x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1) / 2, 
			x3 - x1, y3 - y1, (x3 * x3 - x1 * x1 + y3 * y3 - y1 * y1) / 2, &px, &py);

		r = sqrt((px - x1) * (px - x1) + (py - y1) * (py - y1));

		cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(3)
			<< px << " " << py << " " << r << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
  int n;
  cin>>n;
  double a,b,c,d,e,f,x,y,r,x1,x2,x3,y1,y2,y3;
  for(int i=0;i<n;i++) {
    cin>>x1>>y1>>x2>>y2>>x3>>y3;
    a = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
    b = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
    c = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    d = acos((b * b + c * c - a * a) / (2 * b * c));
    e = acos((a * a + c * c - b * b) / (2 * a * c));
    f = acos((b * b + a * a - c * c) / (2 * b * a));
    x = (x1 * sin(d * 2) + x2 * sin(e * 2) + x3 * sin(f * 2)) / (sin(d * 2) + sin(e * 2) + sin(f * 2));
    y = (y1 * sin(d * 2) + y2 * sin(e * 2) + y3 * sin(f * 2)) / (sin(d * 2) + sin(e * 2) + sin(f * 2));
    r = a / (2 * sin(d));
    cout<<fixed<<setprecision(3)<<x<<" "<<y<<" "<<r<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
 
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		double x[3], y[3], a1, a2, b1, b2, px, py, r;
		for(int i = 0; i < 3; i++){
			cin >> x[i] >> y[i];
		}
		bool check = true;
		if(y[1]-y[0] == 0){
			px = (x[1]+x[0])/2;
			check = false;
		}else{
			a1 = (x[0]-x[1])/(y[1]-y[0]);
			b1 = (y[1]+y[0])/2-a1*(x[1]+x[0])/2;
		}
		if(y[2]-y[0] == 0){
			px = (x[2]+x[0])/2;
			check = false; 
		}else{
			a2 = (x[0]-x[2])/(y[2]-y[0]);
			b2 = (y[2]+y[0])/2-a2*(x[2]+x[0])/2;
		}
		if(check){
			px = (b2-b1)/(a1-a2);
			py = a1*px+b1;	
		}else if(y[1]-y[0] == 0){
			py = a2*px+b2;
		}else if(y[2]-y[0] == 0){
			py = a1*px+b1;
		}
		r = pow(px-x[0], 2)+pow(py-y[0], 2);
		r = sqrt(r);
		cout << fixed << setprecision(3) << px << ' ' << py << ' ' << r << endl;
	}
}