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<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
int main(){
	double x1, x2, x3, y1, y2, y3;
	int n;
	cin >> n;
	rep(i, n){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double a = sqrt(pow(x2-x3,2)+pow(y2-y3,2));
		double b = sqrt(pow(x3-x1,2)+pow(y3-y1,2));
		double c = sqrt(pow(x1-x2,2)+pow(y1-y2,2));
		double A = a*a;
		double B = b*b;
		double C = c*c;
		
		double px= (A*(B+C-A)*x1+B*(C+A-B)*x2+C*(A+B-C)*x3)/(A*(B+C-A)+B*(C+A-B)+C*(A+B-C));
		double py= (A*(B+C-A)*y1+B*(C+A-B)*y2+C*(A+B-C)*y3)/(A*(B+C-A)+B*(C+A-B)+C*(A+B-C));
		double r= a*b*c/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
		printf("%.3lf %.3lf %.3lf\n", px, py, r);
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <functional>
#include <complex>
#include <cmath>
using namespace std;
#define P complex<double>
#define X real()
#define Y imag()
#define EPS 1e-10

class Triangle {
	private:
		P a, b, c;
		double edgeA, edgeB, edgeC;
		double angleA, angleB, angleC;
		double getAngle(double e1, double e2, double e3) {
			return acos((e2 * e2 + e3 * e3 - e1 * e1) / (2 * e2 * e3));
		}
	public:
		Triangle(P p1, P p2, P p3) : a(p1), b(p2), c(p3) {
			edgeA = abs(b - c);
			edgeB = abs(c - a);
			edgeC = abs(a - b);
			angleA = getAngle(edgeA, edgeB, edgeC);
			angleB = getAngle(edgeB, edgeC, edgeA);
			angleC = getAngle(edgeC, edgeA, edgeB);
		}
		
		double getCircumscribedCircleRadius() {
			return edgeA / sin(angleA) / 2;
		}
		
		P getCircumscribedCirclePoint() {
			double A = sin(2 * angleA);
			double B = sin(2 * angleB);
			double C = sin(2 * angleC);
			P p;
			p.X = (a.X * A + b.X * B + c.X * C) / (A + B + C);
			p.Y = (a.Y * A + b.Y * B + c.Y * C) / (A + B + C);
			
			return p;
		}
};

int main()
{	
	int n;
	cin >> n;
	while (n--) {
		P p1, p2, p3;
		scanf("%lf %lf %lf %lf %lf %lf", &p1.X, &p1.Y, &p2.X, &p2.Y, &p3.X, &p3.Y);
		Triangle tr(p1, p2, p3);
		P p = tr.getCircumscribedCirclePoint();
		double r = tr.getCircumscribedCircleRadius();
		
		printf("%.3f %.3f %.3f\n", p.X, p.Y, r);
	}
		
	return 0;
}

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

struct Vector2D {
	double x, y;

	Vector2D() : x(0.0), y(0.0) {}
	Vector2D(double vx, double vy) : x(vx), y(vy) {}
	Vector2D& operator+=(const Vector2D& rhs)
	{
		x += rhs.x;
		y += rhs.y;
		return *this;
	}
	Vector2D& operator-=(const Vector2D& rhs)
	{
		x -= rhs.x;
		y -= rhs.y;
		return *this;
	}
	Vector2D& operator*=(double rhs)
	{
		x *= rhs;
		y *= rhs;
		return *this;
	}
};

Vector2D operator+(const Vector2D& lhs, const Vector2D& rhs)
{
	Vector2D result(lhs);
	return result += rhs;
}

Vector2D operator-(const Vector2D& lhs, const Vector2D& rhs)
{
	Vector2D result(lhs);
	return result -= rhs;
}

Vector2D operator*(double lhs, const Vector2D& rhs)
{
	Vector2D result(rhs);
	return result *= lhs;
}

void solve(Vector2D p1, Vector2D p2, Vector2D p3, Vector2D& center, double& radius)
{
	// p3-base p1, p3-base p2
	Vector2D r1(p1 - p3), r2(p2 - p3);

	double det = r2.x * r1.y - (-r1.x) * r2.y;
	double a = (r2.x * (r2.x - r1.x) + r2.y * (r1.y - r2.y)) * 0.5 / det;

	center = p3 + (0.5 * r1 + a * Vector2D(r1.y, -r1.x));

	Vector2D r = p1 - center;
	radius = sqrt(r.x * r.x + r.y * r.y);
}

int main()
{
	int count = 0;
	std::cin >> count;
	for (int i = 0; i < count; ++i) {
		Vector2D p1,p2,p3;
		std::cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
		if (!std::cin.good()) {
			break;
		}
		Vector2D center;
		double radius = 0.0;
		solve(p1, p2, p3, center, radius);
		std::printf("%.3f %.3f %.3f\n", center.x, center.y, radius);
	}

	return 0;
}

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

int main(){
  double x1,x2,x3,y1,y2,y3,x,n;

  cin >> n;
  int i=0;
  while(i < n){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double sina,R,BC = sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)),p,q;
    sina = ((x2-x1)*(x3-x1) + (y2-y1)*(y3-y1)) / sqrt(((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))*((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1)));

    p = ((y1-y3)*(y1*y1 - y2*y2 + x1*x1 - x2*x2) - (y1-y2)*(y1*y1-y3*y3+x1*x1 -x3*x3))/(2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));
    q = ((x1-x3)*(x1*x1 - x2*x2 + y1*y1 - y2*y2) - (x1-x2)*(x1*x1-x3*x3+y1*y1 -y3*y3))/(2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3));
    R = BC/(2*sina);
    printf("%.3lf %.3lf %.3lf\n",p,q,R);
    i++;
  }
}

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

using namespace std;
 
int aaa(){
    float x1,x2,x3,y1,y2,y3;
    std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    float a = sqrt((x1-x2) * (x1-x2) + (y1-y2) * (y1-y2));
    float b = sqrt((x1-x3) * (x1-x3) + (y1-y3) * (y1-y3));
    float c = sqrt((x2-x3) * (x2-x3) + (y2-y3) * (y2-y3));
    float q = (a+b+c) / 2; 
    float p = sqrt( (q-a) * (q-b) * (q-c) * q);
    float s = (2 * p) / (b * c);
    float r = a / (s * 2);
    a = a*a;
    b = b*b;
    c = c*c;
    float x = ( (b+c-a) * a*x3 + (a+c-b) * b*x2 + (a+b-c) * c*x1 ) / (p*p*16);
    float y = ( (b+c-a) * a*y3 + (a+c-b) * b*y2 + (a+b-c) * c*y1 ) / (p*p*16);
    printf("%.3lf %.3lf %.3lf\n", x, y, r);
    
    return 0;
}
 
int main(){
    int num;
    cin >> num;
    for(int i = 0;i < num; i++){
        aaa();
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
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;

		double a1=2*(x2-x1);
		double b1=2*(y2-y1);
		double c1=x1*x1-x2*x2+y1*y1-y2*y2;
		double a2=2*(x3-x1);
		double 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=sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));

		x=floor(x*1000+0.5)/1000;
		y=floor(y*1000+0.5)/1000;
		r=floor(r*1000+0.5)/1000;

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