Go: package main

import (
	"fmt"
	"math"
)

func main() {
	n := scanInt()
	for i := 0; i < n; i++ {
		cal()
	}
}

func scanInt() int {
	var n int
	fmt.Scanf("%d", &n)
	return n
}

func cal() {
	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 <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;
double a, b, c, d, e, f;
double x, y;


void function(){
	if(c/b == f/e){
		x = 0;
		y = c/b;
	}else if(c/a == f/d){
		y = 0;
		x = c/a;
	}else{
		y = (c*d - a*f)/(d*b - a*e);
		x = (c - b*y)/a;
	}
	return;
}


int main(){
	int n;
	cin >> n;

	for(int i=0 ; i<n ; i++){
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		if((y2-y1) == 0){
			a = 2*(x3 - x1);
			b = 2*(y3 - y1);
			c = (x3 - x1)*(x1 + x3) + (y3 - y1)*(y1 + y3);

			d = 2*(x3 - x2);
			e = 2*(y3 - y2);
			f = (x3 - x2)*(x2 + x3) + (y3 - y2)*(y2 + y3);
		}else if((y3-y1) == 0){

			a = 2*(x2 - x3);
			b = 2*(y2 - y3);
			c = (x2 - x3)*(x2 + x3) + (y2 - y3)*(y2 + y3);

			d = 2*(x2 - x1);
			e = 2*(y2 - y1);
			f = (x2 - x1)*(x1 + x2) + (y2 - y1)*(y1 + y2);
		}else{

			a = 2*(x3 - x1);
			b = 2*(y3 - y1);
			c = (x3 - x1)*(x1 + x3) + (y3 - y1)*(y1 + y3);

			d = 2*(x2 - x1);
			e = 2*(y2 - y1);
			f = (x2 - x1)*(x1 + x2) + (y2 - y1)*(y1 + y2);
		}
		function();
		double r;
		r = sqrt((x - x1)*(x - x1) + (y - y1)*(y - y1));

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

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

typedef complex<double> point;

#define PI M_PI
#define EPS (1e-10)
#define X real()
#define Y imag()

class Triangle{
private:	
	point a,b,c;
	double edgeA,edgeB,edgeC;
	double angleA,angleB,angleC;
	double calc_angle(double a,double b, double c){
		return acos((b*b+c*c-a*a)/(2.0*b*c));
	}
	bool equal(double a, double b){
		return (abs(a-b) < EPS)? true: false;
	}

public:
	Triangle(point p1,point p2,point p3){
		a=p1; b=p2; c=p3;
		edgeA=abs(b-c);
		edgeB=abs(c-a);
		edgeC=abs(a-b);
		angleA=calc_angle(edgeA,edgeB,edgeC);
		angleB=calc_angle(edgeB,edgeC,edgeA);
		angleC=calc_angle(edgeC,edgeA,edgeB);
	}
	double circumscribed_radius(){
		return (edgeA/(2.0*sin(angleA)));
	}
	double circumscribed_X(){
		double A=sin(2.0*angleA);
		double B=sin(2.0*angleB);
		double C=sin(2.0*angleC);
		return((a.X*A+b.X*B+c.X*C)/(A+B+C));
	}
	double circumscribed_Y(){
		double A=sin(2.0*angleA);
		double B=sin(2.0*angleB);
		double C=sin(2.0*angleC);
		return((a.Y*A+b.Y*B+c.Y*C)/(A+B+C));
	}
};

int main(void){
	int x1,y1;
	int x2,y2;
	int x3,y3;
	int n;
	int r,x,y;

	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		point a(x1,y1);
		point b(x2,y2);
		point c(x3,y3);
		Triangle Tr(a,b,c);
		r=Tr.circumscribed_radius();
		x=Tr.circumscribed_X();
		y=Tr.circumscribed_Y();
		cout << fixed;
		cout.precision(3);
		cout << r << " " << x << " " << y << endl;
	}
	return 0;
}

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

int main(void){
	int n;
	cin >> n;
	double x1,x2,x3,y1,y2,y3;
	for(int i = 0 ; i < n ; i ++){
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		double a = x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1;
		double b = x3 * x3 - x1 * x1 + y3 * y3 - y1 * y1;
		double c = 4 * (x2 - x1) * (y3 - y1) - 4 * (x3 - x1) * (y2 - y1);
		
		double x = (2 * (y3 - y1) * a - 2 * (y2 - y1) * b ) / c;
		double y = (-2 * (x3 - x1) * a + 2 * (x2 - x1) * b ) / c;
		double r = sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
		
		printf("%.3lf %.3lf %.3lf\n",x,y,r);
		
	} 
	return 0;
}

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

struct TCoordinate
{
	double x;
	double y;
};

TCoordinate GetCenterPoint(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	double x1 = P1.x;
	double x2 = P2.x;
	double x3 = P3.x;
	double y1 = P1.y;
	double y2 = P2.y;
	double y3 = P3.y;
	double x, y, r;
	if(y1 == y2 || y2 == y3 || y3 == y1){
		if(y2 == y3){
			swap(x3, x1);
			swap(y3, y1);
		}else if(y3 == y1){
			swap(x2, x3);
			swap(y2, y3);
		}
		double xa = (x2 + x3) / 2;
		double ya = (y2 + y3) / 2;
		double a  = (-x3 + x2) / (y3 - y2);
		x = (x1 + x2) / 2;
		y = a * (x - xa) + ya;
	}else{
		double xa = (x1 + x2) / 2;
		double ya = (y1 + y2) / 2;
		double a  = (-x2 + x1) / (y2 - y1);
		double xb = (x2 + x3) / 2;
		double yb = (y2 + y3) / 2;
		double b  = (-x3 + x2) / (y3 - y2);
		x = (b * xb - a * xa - yb + ya) / (b - a);
		y = a * (x - xa) + ya;
	}
	return {x, y};
}

double GetRadius(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	double x1 = P1.x;
	double x2 = P2.x;
	double x3 = P3.x;
	double y1 = P1.y;
	double y2 = P2.y;
	double y3 = P3.y;
	double x, y, r;
	if(y1 == y2 || y2 == y3 || y3 == y1){
		if(y2 == y3){
			swap(x3, x1);
			swap(y3, y1);
		}else if(y3 == y1){
			swap(x2, x3);
			swap(y2, y3);
		}
		double xa = (x2 + x3) / 2;
		double ya = (y2 + y3) / 2;
		double a  = (-x3 + x2) / (y3 - y2);
		x = (x1 + x2) / 2;
		y = a * (x - xa) + ya;
	}else{
		double xa = (x1 + x2) / 2;
		double ya = (y1 + y2) / 2;
		double a  = (-x2 + x1) / (y2 - y1);
		double xb = (x2 + x3) / 2;
		double yb = (y2 + y3) / 2;
		double b  = (-x3 + x2) / (y3 - y2);
		x = (b * xb - a * xa - yb + ya) / (b - a);
		y = a * (x - xa) + ya;
	}
	return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
}

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		TCoordinate P1, P2, P3;
		cin >> P1.x >> P1.y >> P2.x >> P2.y >> P3.x >> P3.y;
		TCoordinate CenterPoint = GetCenterPoint(P1, P2, P3);
		double Radius = GetRadius(P1, P2, P3);
		cout << fixed << setprecision(3) << CenterPoint.x << ' ' << CenterPoint.y << ' ' << Radius << endl;
	}
	return 0;
}

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

void gradcut(double *a,double *b,double x1,double y1,double x2,double y2);

int main(int argc, const char * argv[]) {
    double x[3],y[3],a[2],b[2],rx,ry,r;
    int n;
    std::cin >> n;
    for(int j=0;j<n;j++){
        int am=0,add=1;;
        for(int i=0;i<3;i++) std::cin >> x[i] >> y[i];
        for(int i=0;i<3;i++){
            if(i==2) add=-2;
            if(x[i]!=x[i+add]&&y[i]!=y[i+add]){
                gradcut(&a[am],&b[am],x[i],x[i+add],y[i],y[i+add]);
                am++;
                if(am>2) break;
            }else if(x[i]==x[i+add]){
                a[am]=0;
                b[am]=(y[i]+y[i+add])/2;
                am++;
                if(am>2) break;
            }
        }


        rx = (b[1]-b[0])/(a[0]-a[1]);
        ry = a[0]*rx+b[0];
        r=sqrt((x[0]-rx)*(x[0]-rx)+(y[0]-ry)*(y[0]-ry));
        printf("%.3f %.3f %.3f\n",rx,ry,r);
    }
    return 0;
}

void gradcut(double *a,double *b,double x1,double x2,double y1,double y2){

    *a=(y2-y1)/(x2-x1);
    *b=y1-*a*x1;
}

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

int main(){
	int n;
	double x1,y1,x2,y2,x3,y3,x1_2,x1_3,y1_2,y1_3,z1_2,z1_3,a,b,c,r;
	while(cin >> n){
		for(int i = 0;i < n;++i){
			cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
			z1_2 = (((x1 * x1) + (y1 * y1)) * -1) - (((x2 * x2) + (y2 * y2)) * -1);
			z1_3 = (((x1 * x1) + (y1 * y1)) * -1) - (((x3 * x3) + (y3 * y3)) * -1);
			x1_2 = x1 - x2;
			x1_3 = x1 - x3;
			y1_2 = y1 - y2;
			y1_3 = y1 - y3;
			a = ((y1_2 * z1_3) - (y1_3 * z1_2)) / ((y1_2 * x1_3) - (y1_3 * x1_2));
			b = ((x1_2 * z1_3) - (x1_3 * z1_2)) / ((x1_2 * y1_3) - (x1_3 * y1_2));
			c = ((x1 * x1) + (y1 * y1) + (a * x1) + (b * y1)) * -1;
			r = sqrt((c * -4) + (a * a) + (b * b)) / 2.0;
			printf("%.3f %.3f %.3f\n",a / -2.0,b / -2.0,r);
		}
	}
	return 0;
}