Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var num int
	fmt.Scan(&num)
	for i := 0; i < num; i++ {
		var x1, y1, x2, y2, x3, y3 float64
		fmt.Scanf("%f%f%f%f%f%f", &x1, &y1, &x2, &y2, &x3, &y3)

		a := 2 * (x2 - x1)
		b := 2 * (y2 - y1)
		c := 2 * (x3 - x1)
		d := 2 * (y3 - y1)
		e := x2*x2 - x1*x1 + y2*y2 - y1*y1
		f := x3*x3 - x1*x1 + y3*y3 - y1*y1

		// 直線1: ax + by - e = 0
		// 直線2: cx + dy - f = 0
		px := (d*e - b*f) / (a*d - b*c)
		py := (c*e - a*f) / (b*c - a*d)
		r := math.Sqrt((px-x1)*(px-x1) + (py-y1)*(py-y1))
		fmt.Printf("%.3f %.3f %.3f\n", px, py, r)
	}
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
double zeti(double);
int main() {
    pair<double, double> a;
    pair<double, double> b;
    pair<double, double> c;
    pair<double, double> m1;
    pair<double, double> m2;
    double s1, s2,x1,y1,x2,y2,x,y,b1,b2;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        x = -1000.0;
        y = -1000.0;
        b1 = 0.0;
        b2 = 0.0;
        s1 = -1000.0;
        s2 = -1000.0;
        scanf("%lf%lf", &a.first, &a.second);
        scanf("%lf%lf", &b.first, &b.second);
        scanf("%lf%lf", &c.first, &c.second);
        m1.first = (a.first + b.first) / 2.0;
        m1.second = (a.second + b.second) / 2.0;
        m2.first = (b.first + c.first) / 2.0;
        m2.second = (b.second + c.second) / 2.0;
        //swap(m1.first, m1.second);
        //swap(m2.first, m2.second);
        //x is qual
        if (a.first - b.first == 0) {
            x = m1.second;
            b1 = m1.second;
            s1=0;
        }
        //y is qual
        else if (a.second - b.second == 0) {
            
            y = m1.first;
            
        }
        else {
            s1 = (zeti(a.second - b.second)) / (zeti(a.first - b.first));
            s1 = 1.0 / s1*-1.0;
            b1 = m1.second - s1*m1.first;
        }
        //x is qual
        if (b.first - c.first == 0) {
            x = m2.second;
            b2 = m2.second;
            s2=0;
        }
        //y is qual
        else if (b.second - c.second == 0) {
            y = m2.first;
        }
        else {
            s2 = (zeti(c.second - b.second)) / (zeti(c.first - b.first));
            s2 = 1.0 / s2*-1.0;
            b2 = m2.second - s2*m2.first;
        }
        double r,w,e;
        if(x!=-1000.0){
            if(s1==-1000.0){
                y=s2*x+b2;
            }
            else{
                y=s1*x+b2;
            }
            w = zeti(a.first - x);
            e = zeti(a.second - y);
            r = sqrt(w*w+e*e);
            printf("%.3lf %.3lf %.3lf\n", x, y,r);
            return 0;
            
        }
        if(y!=-1000.0){
            cout<<"b"<<endl;
            if(s1==-1000.0){
                x=(y-b2)/s2;
            }
            else{
                x=(y-b1)/s1;
            }
            w = zeti(a.first - x);
            e = zeti(a.second - y);
            r = sqrt(w*w+e*e);
            printf("%.3lf %.3lf %.3lf\n", x, y,r);
            return 0;
        }
        if (x == -1000.0) {
            x = (b1 - b2) / (s2 - s1);
        }
        if (y==-1000.0) {
            y = s2*x + b2;
        }
        
        
        w = zeti(a.first - x);
        e = zeti(a.second - y);
        r = sqrt(w*w+e*e);
        printf("%.3lf %.3lf %.3lf\n", x, y,r);
        
    }
    return 0;
}
double zeti(double center) {
    if (center < 0) {
        center *= -1;
    }
    return center;
}

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

using namespace std;

int n;
int tx1, ty1, tx2, ty2, tx3, ty3;

int main()
{
	cin >> n;
	for(int i=0; i<n; i++)
	{
		cin >> tx1 >> ty1;
		cin >> tx2 >> ty2;
		cin >> tx3 >> ty3;

		double mx1 = (tx1 + tx2) / 2.0;
		double my1 = (ty1 + ty2) / 2.0;
		double a1 = (double)(tx2 - tx1);
		double b1 = (double)(ty2 - ty1);
		double c1 = a1 * mx1 + b1 * my1;

		double mx2 = (tx2 + tx3) / 2.0;
		double my2 = (ty2 + ty3) / 2.0;
		double a2 = (double)(tx3 - tx2);
		double b2 = (double)(ty3 - ty2);
		double c2 = a2 * mx2 + b2 * my2;

		double det = a1 * b2 - a2 * b1;
		
		double cx = (b2 * c1 - a2 * c2) / det;
		double cy = (-a2 * c1 + a1 * c2) / det;
		
		double dx = cx - tx1;
		double dy = cy - ty1;
		double r = sqrt(dx*dx + dy*dy);
		
		printf("%1.3f %1.3f %1.3f\n", cx, cy, r);
	}
}

C++: #include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef double D;
typedef complex<D> P;
typedef vector<P> VP;
P minEnclosingCircle(const VP& ps) {
  P c;
  double move = 0.5;
  r(i,39) {  // 2^(-39-1) \approx 0.9e-12
    r(t,100) {
      D max = 0;
      int k = 0;
      r (j, ps.size()) if (max < norm(ps[j]-c)) {
        max = norm(ps[j]-c);
        k = j;
      }
      c += (ps[k]-c) * move;
    }
    move /= 2;
  }
  return c;
}
int main(){
    int n;
    cin>>n;
    r(i,n){
        VP p;
        D a,b;
        r(j,3){
            cin>>a>>b;
            p.push_back(P(a,b));
        }
        P t=minEnclosingCircle(p);
        D dis=abs(p[0]-t);
        printf("%.3f %.3f %.3f\n",t.real(),t.imag(),dis);
    }
}

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

int main()
{
	int i,n,flg=0;
	double x1,x2,x3,y1,y2,y3;
	double m1,m2,xm1,xm2,ym1,ym2,xo,yo,r;
	//m1,m2…辺の法線　xm1,ym1…辺の中点の座標

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

		xm1=(x1+x2)/2;
		xm2=(x2+x3)/2;
		ym1=(y1+y2)/2;
		ym2=(y2+y3)/2;
		if(y1-y2!=0){
			m1=(-1)*(x1-x2)/(y1-y2);
		}else if(y1-y2==0) flg=1;
		if(y2-y3!=0){
			m2=(-1)*(x2-x3)/(y2-y3);
		}else flg=2;
		if(flg==0){
			xo=(m1*xm1-m2*xm2+ym2-ym1)/(m1-m2);
		}else if(flg==1) xo=xm1;
		else if(flg=2) xo=xm2;
		if(flg==1) yo=m2*(xo-xm2)+ym2;
		r=sqrt((x1-xo)*(x1-xo)+(y1-yo)*(y1-yo));
//		cout<<fixed<<setprecision(5)<<m1<<" "<<m2<<endl;
		printf("%.3lf %.3lf %.3lf \n",xo,yo,r);
	}
}

C++: #include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		double x1, y1, x2, y2, x3, y3, px, py, r;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		px = ((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));
		py = ((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 = sqrt((x1 - px) * (x1 - px) + (y1 - py) * (y1 - py));
		printf("%.3lf %.3lf %.3lf\n", px, py, r);
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main() {

	int n;
	double x1, x2, x3, y1, y2, y3;
	double X, Y, R;
	double a, b, c, d;

	double x[20] = {0}, y[20] = { 0 }, r[20] = { 0 };

	cin >> n;

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

		a = x2 - x1;
		b = x3 - x1;
		c = y2 - y1;
		d = y3 - y1;
	
		X = 0.5*((a*a*d - b*b*c) + c*d*(d - c)) / (a*d - b*c);
		Y = 0.5*(a*b*(a - b) + (b*c*c - a*d*d)) / (b*c - a*d);
		R = sqrt(X*X + Y*Y);

		X += x1;
		Y += y1;
		
		//?°???°????¬¬??????????????¨?????\
		if (X > 0)
			X = (int)(X * 1000 + 0.5);
		else X = (int)(X * 1000 - 0.5);

		if (Y>0)
			Y = (int)(Y * 1000 + 0.5);
		else Y = (int)(Y * 1000 - 0.5);

		if (R < 0)
			R = -R;
		R = (int)(R * 1000 + 0.5);
		x[i] = X / 1000;
		y[i] = Y / 1000;
		r[i] = R / 1000;
		
	//	printf("%.3lf %.3lf %.3lf\n", X/1000 , Y /1000, R /1000);
	}

	for (int i = 0; i < n; i++) {
		printf("%.3lf %.3lf %.3lf\n", x[i], y[i], r[i]);
	}

	return 0;
}