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

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

		double x,y;
		double ax,ay,am,bx,by,bm;


		if(y1==y2){
			x = (x1+x2)/2;
			bx = (x2+x3)/2;
			by = (y2+y3)/2;
			bm = -(x2-x3)/(y2-y3);
			y = bm*(x-bx)+by;
		}else if(y2==y3){
			x = (x2+x3)/2;
			ax = (x1+x2)/2;
			ay = (y1+y2)/2;
			am = -(x1-x2)/(y1-y2);
			y = am*(x-ax)+ay;
		}else{
			ax = (x1+x2)/2;
			ay = (y1+y2)/2;
			am = -(x1-x2)/(y1-y2);	
			bx = (x2+x3)/2;
			by = (y2+y3)/2;
			bm = -(x2-x3)/(y2-y3);

			x = (am*ax-bm*bx-ay+by)/(am-bm);
			y = am*(x-ax)+ay;
		}
		
		printf("%.3lf %.3lf %.3lf\n", x, y, sqrt(pow(x1-x, 2)+pow(y1-y,2)));
	}
}

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

int main() {
    int n;
    cin >> n;
    while(n--) {
        double x1, x2, x3, y1, y2, y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        double a1, a2, b1, b2, c1, c2,x, y, r;
        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;
        
        x = (double)(b1*c2-b2*c1)/(double)(a1*b2-a2*b1);
        y = (double)(c1*a2-c2*a1)/(double)(a1*b2-a2*b1);
        r = (double)sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
        
        printf("%.3f %.3f %.3f\n",x,y,r);
    }
    return 0;
}

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

int main(){
	double x[3], y[3], xp, yp, r;
	int n;
	scanf("%d", &n );
	for( int i=0; i<n; i++ ){
		scanf("%lf %lf %lf %lf %lf %lf", &x[0], &y[0], &x[1], &y[1], &x[2], &y[2]);
		double A1 = 2.0 * (x[1]-x[0]);
		double B1 = 2.0 * (y[1]-y[0]);
		double C1 = x[0]*x[0] - x[1]*x[1] + y[0]*y[0] - y[1]*y[1];
		double A2 = 2.0 * (x[2]-x[0]);
		double B2 = 2.0 * (y[2]-y[0]);
		double C2 = x[0]*x[0] - x[2]*x[2] + y[0]*y[0] - y[2]*y[2];
		xp = (B1*C2-B2*C1)/(A1*B2-A2*B1);
		yp = (C1*A2-C2*A1)/(A1*B2-A2*B1);
		r = sqrt( (xp-x[0])*(xp-x[0])+(yp-y[0])*(yp-y[0]) );
		printf("%.3f %.3f %.3f\n", xp, yp, r);
	}
	return 0;
}

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

using namespace std;

int main(){
	int cnt;
	cin >> cnt;
	double x1, y1, x2, y2, x3, y3;
	double a1, a2, b1, b2, c1, c2;
	double xp, yp, r;
	while (cnt > 0 && cin >> 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 - x1);
		b2 = 2 * (y3 - y1);
		c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;
		xp = (double)((b1*c2 - b2*c1) / (a1*b2 - a2*b1) * 1000) / 1000.0;
		yp = (double)((c1*a2 - c2*a1) / (a1*b2 - a2*b1) * 1000) / 1000.0;

		// ?????\????????????????±???????
		r = hypot(xp - x1, yp - y1);

		cout << fixed << setprecision(3);
		cout << xp << " " << yp << " " << r << endl;
		cnt -= 1;
	}
	return 0;
}

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

// 点座標を型とする
typedef complex<double> P;
// πの定義
#define PI 3.1415926535898

// 許容する誤差ε
#define EPS (1e-10)
//XY座標
#define X real()
#define Y imag()
	
// 三角形クラス
class Triangle{

private:
	//三角形の３点の座標
	P a, b, c;
	//三角形の３辺の長さ
	double edgeA,edgeB,edgeC;
	//三角形の３角の大きさ(ラジアン)
	double angleA,angleB,angleC;
	//余弦定理から３つの角度を求める関数
	double LawOfCosines(double a,double b, double c){
		return acos( (b*b+c*c-a*a) / (2.0*b*c) );
	}
	//２つのdouble型の数値が等しいかどうか
	bool equal(double a, double b){
		return (abs( a-b ) < EPS)? true : false ;
	}

public:
	//コンストラクタ(３つの点と辺と角度を初期化)
	Triangle(P p1, P p2, P p3){
		a = p1;
		b = p2;
		c = p3;
		edgeB = abs(c-a);
		edgeA = abs(b-c);
		edgeC = abs(a-b);
		angleA = LawOfCosines(edgeA,edgeB,edgeC);
		angleB = LawOfCosines(edgeB,edgeC,edgeA);
		angleC = LawOfCosines(edgeC,edgeA,edgeB);
	}
	
	double circumscribedCircleRadius(){//外接円の半径を返す
		return ( edgeA / sin(angleA) / 2.0 );
	}
	double circumscribedCircleX(){//外心(外接円の中心)の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 circumscribedCircleY(){//外心(外接円の中心)の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(){
	int n;
	double x1, x2, x3, y1, y2, y3;
	double r, xp, yp;

	scanf("%d", &n);
	for (int i=0 ; i<n ; i++){
		scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
		P a( x1 , y1 );
		P b( x2 , y2 );
		P c( x3 , y3 );
		Triangle Tr(a,b,c);
		r  = Tr.circumscribedCircleRadius();
		xp = Tr.circumscribedCircleX();
		yp = Tr.circumscribedCircleY();
		printf("%.3f %.3f %.3f\n", xp,yp,r);
	}
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  double x1, y1, x2, y2, x3, y3;
  double px, py;
  double r;
  double M1, mx1, my1;
  double M2, mx2, my2;
  int n;
  cin >> n;

  while(1){
    if(n == 0) break;

    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    mx1 = (x1 + x2) / 2;
    my1 = (y1 + y2) / 2;
    if(y1 - y2 == 0) M1 = 0;
    else  M1 = (x2 - x1) / (y1 - y2);
   

    mx2 = (x2 + x3) / 2;
    my2 = (y2 + y3) / 2;
    if(y2 - y3 == 0) M2 = 0;
    else  M2 = (x3 - x2) / (y2 -y3);
    

    if(M1 == M2){
      px = mx1;
      py = my2;
    }
    else if(M1 != M2){
      px = (M1*mx1 - my1 - M2*mx2 + my2) / (M1 - M2);
      py = M1*(px - mx1) + my1;
    }

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

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

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

// ax + by = e1
// cx + dy = e2
auto solve (double a , double b , double c , double d , double e1 , double e2) -> std::pair <double , double>
{
    auto delta = a * d - b * c;
    auto x = (d * e1 - b * e2) / delta;
    auto y = (a * e2 - c * e1) / delta;
    return std::make_pair (std::move (x) , std::move (y));
}

auto distance (const std::pair <double , double> & a , const std::pair <double , double> & b) -> double
{
    auto dx = a.first  - b.first;
    auto dy = a.second - b.second;
    return std::sqrt (dx * dx + dy * dy);
}

auto show (double v) -> std::string
{
    if (-0.5 < v && v < 0)
    {
        return "0.000";
    }
    char s [100];
    std::sprintf (s , "%.3f" , v);
    return s;
}

auto main () -> int
{
    int n;
    std::cin >> n;
    for (auto i = 0; i < n; ++ i)
    {
        double x1 , y1 , x2 , y2 , x3 , y3;
        std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        auto b1 = (y2 - y1) * (y1 + y2) / 2 + (x2 - x1) * (x1 + x2) / 2;
        auto b2 = (y3 - y1) * (y1 + y3) / 2 + (x3 - x1) * (x1 + x3) / 2;
        auto p = solve ((x2 - x1) , (y2 - y1) , (x3 - x1) , (y3 - y1) , b1 , b2);
        auto r = distance (p , std::make_pair (x1 , y1));
        std::cout << show (p.first) << ' ' << show (p.second) << ' ' << show (r) << std::endl;
    }
}