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>

struct Zahyou
{
	float x, y;
};

int main()
{
	int n;
	Zahyou de[4];

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 1; j < 4; j++)
		{
			scanf("%f %f", &de[j].x, &de[j].y);
		}
		de[0].x = ((de[1].y - de[3].y)*(pow(de[1].y, 2) - pow(de[2].y, 2) + pow(de[1].x, 2) - pow(de[2].x, 2)) + (de[1].y - de[2].y)*(pow(de[1].y, 2) - pow(de[3].y, 2) + pow(de[1].x, 2) - pow(de[3].x, 2))) / (2 * (de[1].y - de[3].y)*(de[1].x - de[2].x) + 2 * (de[1].y - de[2].y)*(de[1].x - de[3].x));
		de[0].y = ((de[1].x - de[3].x)*(pow(de[1].x, 2) - pow(de[2].x, 2) + pow(de[1].y, 2) - pow(de[2].y, 2)) + (de[1].x - de[2].y)*(pow(de[1].x, 2) - pow(de[3].x, 2) + pow(de[1].y, 2) - pow(de[3].y, 2))) / (2 * (de[1].x - de[3].x)*(de[1].y - de[2].y) + 2 * (de[1].x - de[2].x)*(de[1].y - de[3].y));
		
		printf("%.3f %.3f %.3f\n",de[0].x,de[0].y,sqrt(pow((de[0].x-de[1].x),2)+pow((de[0].y-de[1].y),2)));
	}
	return 0;
}

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

/*
  P1(x1, y1) P2(x2, y2) P3(x3, y3) P0(x0, y0)

 <円の中心(x0, y0)>
  2*(x2-x1)*x0 + 2*(y2-y1)*y0 = x2*x2 - x1*x1 + y2*y2 - y1*y1
  2*(x3-x1)*x0 + 2*(y3-y1)*y0 = x3*x3 - x1*x1 + y3*y3 - y1*y1
  x0=((y3-y1)*(x2*x2-x1*x1+y2*y2-y1*y1)+(y1-y2)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*(x2-x1)*(y3-y1)-(y2-y1)*(x3-x1))
  y0=((x1-x3)*(x2*x2-x1*x1+y2*y2-y1*y1)+(x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*(x2-x1)*(y3-y1)-(y2-y1)*(x3-x1))

 <円の半径R>
  R = a/(2*sqrt(q-cosA*cosA)) 
  a = sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) ) // P2-P3
  b = sqrt( (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) ) // P1-P3
  c = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) ) // P1-P2
  cosA = (b*b + c*c - a*a)/(2*b*c)
 */

int main()
{
    double x1, x2, x3, y1, y2, y3; // 3角形の3点
    int n;
    cin >> n;

    for(int i=0; i<n; i++){
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        double x0=((y3-y1)*(x2*x2-x1*x1+y2*y2-y1*y1)+(y1-y2)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)));
        double y0=((x1-x3)*(x2*x2-x1*x1+y2*y2-y1*y1)+(x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)));
        double a = sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) );
        double b = sqrt( (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) );
        double c = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );
        double cosA = (b*b + c*c - a*a)/(2*b*c);
        double R = a/(2*sqrt(1-cosA*cosA));

        printf("%.3f %.3f %.3f\n", x0, y0, R);
    }

    return 0;
}

C++: #include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
#include <complex>
  
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second
  
const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef complex<double> P;
int n;
  
double cross(P p1,P p2) {
    return (real(p1)*imag(p2) - imag(p1)*real(p2));
}
double calc_S(P p1,P p2,P p3) {
    double ret = 0.0;
    p1 -= p3;
    p2 -= p3;
  
    ret = cross(p1,p2)/2.0;
      
    return abs(ret);
}
  
int main() {
    cin>>n;
    while(n-->0) {
        double x1_,y1_;
        double x2_,y2_;
        double x3_,y3_;
        cin>>x1_>>y1_>>x2_>>y2_>>x3_>>y3_;
        P p1(x1_,y1_);
        P p2(x2_,y2_);
        P p3(x3_,y3_);
        P A = p1-p2;
        P B = p2-p3;
        P C = p1-p3;
        double S = calc_S(p1,p2,p3);
        double R = abs(A)*abs(B)*abs(C)/S;
        R /= 4.0;
          
        P A1 = 2.0*(p2-p1);
        P B1 = 2.0*(p3-p1);
        P C1 = P(norm(p1)-norm(p2),norm(p1)-norm(p3));
        double X = cross(P(imag(A1),imag(B1)),C1)/cross(A1,B1);
        double Y = cross(C1,P(real(A1),real(B1)))/cross(A1,B1);
        printf("%.3lf %.3lf %.3lf\n",X,Y,R);
  
    }
    return 0;
}

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;


double A[2][2];
double C[2];


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);
		int xc_ = xc * 10000;
		int yc_ = yc * 10000;
		int d_ = d*10000;
		xc += ((int)xc_ % 10) > 4 ? xc>0? 0.001 : -0.001 : 0;
		yc += ((int)yc_ % 10) > 4 ? yc>0? 0.001 : -0.001 : 0;
		d += ((int)d_ % 10) > 4 ? 0.001 : 0;


		printf("%.3lf %.3lf %.3lf\n", xc, yc,d );


	}

}

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

using namespace std;

int n;
double x[4],y[4],r;

int main(){
	cin >> n;
	while(n--){
		for(int i=0;i<3;i++){
			cin >> x[i] >> y[i];
		}
		x[3]=((y[2]-y[1])*(x[1]-x[0])*(x[2]-x[0])-(y[1]-y[0])*(x[1]+x[0])*(x[2]-x[0])+(y[2]-y[0])*(x[1]-x[0])*(x[2]+x[0]))/(2*(y[2]-y[0])*(x[1]-x[0])-(y[1]-y[0])*(x[2]-x[0]));
		y[3]=(y[0]+y[1])/2-(y[1]-y[0])*(x[3]-(x[0]+x[1])/2)/(x[1]-x[0]);
		r=sqrt(pow((x[3]-x[2]),2)+pow((y[3]-y[2]),2));
		printf("%.3lf %.3lf %.3lf\n",x[3]+0.00001,y[3]+0.00001,r);
	}
	return 0;
}