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 <cmath>
#include <iomanip>

using namespace std;

    // 半径取得の処理
double getR(double x1, double y1, double x2, double y2, double x3, double y3) {
    
    double marginX1, marginX2, marginX3;
    double marginY1, marginY2, marginY3;
    double a, b, c;
    double r, s;
    
        // それぞれのxとyの長さを求める
    marginX1 = abs(x2 - x1);
    marginY1 = abs(y2 - y1);
    marginX2 = abs(x1 - x3);
    marginY2 = abs(y1 - y3);
    marginX3 = abs(x3 - x2);
    marginY3 = abs(y3 - y2);
    
        // それぞれの辺の長さを求める
    a = sqrt(pow(marginX1,2) + pow(marginY1,2));
    b = sqrt(pow(marginX2,2) + pow(marginY2,2));
    c = sqrt(pow(marginX3,2) + pow(marginY3,2));
    
        // 半径を求める
    s = (a + b + c) / 2;
    r = (a * b * c) / (4 * sqrt(s * (s - a) * (s - b) * (s - c)));
    
    /*
    r *= 10000;
    r = (int)r;
    r /= 10;
    r = round(r);
    r /= 1000;
    */
    
    return r;
}

    // 中心座標を求める処理
void getCentralCoodinate(double x1, double y1, double x2, double y2, double x3, double y3, double *xp, double *yp) {
    
    double marginX1, marginX2;
    double marginY1, marginY2;
    double marginXp1, marginXp2;
    double marginYp1, marginYp2;
    double n, m;
    
        // 初期化
    *xp = 0;
    *yp = 0;
    
        // それぞれのxとyの長さを求める
    marginX1 = abs(x2 - x1);
    marginY1 = abs(y2 - y1);
    marginX2 = abs(x1 - x3);
    marginY2 = abs(y1 - y3);
    
        // 中心座標を求めるのに必要な式
    marginXp1 = 2 * marginX1;
    marginYp1 = 2 * marginY1;
    marginXp2 = 2 * marginX2;
    marginYp2 = 2 * marginY2;
    
    n = pow(x1,2) - pow(x2,2) + pow(y1,2) - pow(y2,2);
    m = pow(x1,2) - pow(x3,2) + pow(y1,2) - pow(y3,2);
    
    *xp = (marginYp1 * m - marginYp2 * n) / (marginXp1 * marginYp2 - marginXp2 * marginYp1);
    *yp = (marginXp2 * n - marginXp1 * m) / (marginXp1 * marginYp2 - marginXp2 * marginYp1);
    
    /*
    *xp *= 10000;
    *xp = (int)*xp;
    *xp /= 10;
    *xp = round(*xp);
    *xp /= 1000;
    
    *yp *= 10000;
    *yp = (int)*yp;
    *yp /= 10;
    *yp = round(*yp);
    *yp /= 1000;
    */
}

    // main処理
int main(void) {
    double x1, x2, x3;
    double y1, y2, y3;
    double xp, yp;
    double r;
    int n;
    
    cin >> n;
    
    while(n--) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        
            // 半径と中心座標を取得する処理
        r = getR(x1, y1, x2, y2, x3, y3);
        getCentralCoodinate(x1, y1, x2, y2, x3, y3, &xp, &yp);
        
            // 出力
        cout << setprecision(3);
        cout << setiosflags(ios::fixed);
        cout << xp << " " << yp << " " << r << endl;
    }

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

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 dx=x1, dy=y1; //平行移動
		x1-=dx; x2-=dx; x3-=dx;
		y1-=dy; y2-=dy; y3-=dy;
		
		double ansx, ansy;
		
		if(y2==0){
			ansx = x2/2.0;
			double b3= x3*x3/y3/2.0 + y3/2.0;
			ansy = -x3*ansx/y3+b3;			
		}
		else if(y3==0){
			ansx = x3/2.0;
			double b2= x2*x2/y2/2.0 + y2/2.0;
			ansy = -x2*ansx/y2+b2; 
		}
		else{
			double b2= x2*x2/y2/2.0 + y2/2.0;
			double b3= x3*x3/y3/2.0 + y3/2.0;

			ansx = (b2-b3)*y2*y3/(x2*y3-x3*y2);
			ansy = -x2*ansx/y2+b2; 			
		}
		
		double r=sqrt(ansx*ansx + ansy*ansy);
		//printf("r=%lf\n", r);
		r*=1000;
		r=round(r);
		r/=1000;
		
		printf("%.3lf %.3lf %.3lf\n", ansx+dx, ansy+dy, r);
		
	}	
}

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

using namespace std;

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

  cin >> datasetnum;

  for (int loopcount = 0; loopcount < datasetnum; loopcount++) {
    double px,py,r;

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

    double len_1 = sqrt(pow(x3-x2,2)+pow(y3-y2,2));
    double len_2 = sqrt(pow(x1-x3,2)+pow(y1-y3,2));
    double len_3 = sqrt(pow(x2-x1,2)+pow(y2-y1,2));

    double s = (len_1+len_2+len_3)/2;
    double area = sqrt(s*(s-len_1)*(s-len_2)*(s-len_3));

    double sin_1 = 2*area/(len_2*len_3);

    r = len_1/(2*sin_1);

    double a = x1 - x3;
    double b = y1 - y3;
    double c = pow(x1,2)-pow(x3,2)+pow(y1,2)-pow(y3,2);
    double d = x2 - x3;
    double e = y2 - y3;
    double f = pow(x2,2)-pow(x3,2)+pow(y2,2)-pow(y3,2);

    px = (c*e-b*f)/(2*(a*e-b*d));
    py = (c*d-a*f)/(2*(b*d-a*e));

    cout << setprecision(4) << px << " " << py << " " << r << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    double x1,y1,x2,y2,x3,y3;
    int n;
 
    scanf("%d",&n);
 
    double a,b,c;
    double ans = 0;
    double xp,yp;
    for(int i = 0;i < n; i++){
        scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
 
        a = hypot(x2 - x1,y2 - y1);
        b = hypot(x3 - x1,y3 - y1);
        c = hypot(x3 - x2,y3 - y2);
 
        ans = (a*b*c) / (sqrt((a+b+c)*(b+c-a)*(a-b+c)*(a+b-c)));
        xp = (((x1*x1)+(y1*y1))*(y2-y3)+((x2*x2)+(y2*y2))*(y3-y1)+((x3*x3)+(y3*y3))*(y1-y2))/(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2;
        yp = (((x1*x1)+(y1*y1))*(x2-x3)+((x2*x2)+(y2*y2))*(x3-x1)+((x3*x3)+(y3*y3))*(x1-x2))/(y1*(x2-x3)+y2*(x3-x1)+y3*(x1-x2))/2;
        printf("%.3lf %.3lf %.3lf\n",xp,yp,ans);
        ans = 0;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#define INF 100000000
using namespace std;
#define pw(a) (a)*(a)

int main(){
  double x1,x2,x3,y1,y2,y3;
  int n;
  cin >> n;
  while(n--){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double a,b,l,m,n;
    a = -1*(pw(x1) - pw(x2) + pw(y1) - pw(y2));
    b = -1*(pw(x1) - pw(x3) + pw(y1) - pw(y3));
    l = (a*(y1-y3)-b*(y1-y2))/((y1-y3)*(x1-x2)-(x1-x3)*(y1-y2));
    m = (b-(x1-x3)*l)/(y1-y3);
    n = -1*(pw(x1) + pw(y1)+ l*x1 + m*y1);
    printf("%.3f %.3f %.3f\n",(float)-l/2,(float)-m/2,(float)sqrt((pw(l) + pw(m) - 4*n))/2);
  }
  return 0;
}

C++: #include<stdio.h>
#include<math.h>
 
int main(void)
{
 double x,y,r;
 double x1,x2,x3,y1,y2,y3;
 double ecm[3][2];
 double a,b,A; //enlarged coefficient matrix:拡大係数行列
 int i;
 int n;
 
 scanf("%d",&n);
 for(i = 0; i < n; i++)
 {
  scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
  ecm[0][0] = x1 - x2;
  ecm[0][1] = y1 - y2;
  ecm[0][2] = (x2*x2 + y2*y2) - (x1*x1 + y1*y1);
  ecm[1][0] = x1 - x3;
  ecm[1][1] = y1 - y3;
  ecm[1][2] = (x3*x3 + y3*y3) - (x1*x1 + y1*y1);
  A = (ecm[0][0]*ecm[1][1])-(ecm[0][1]*ecm[1][0]); 
  a = ((ecm[0][2]*ecm[1][1])-(ecm[0][1]*ecm[1][2]))/A+0;
  b = ((ecm[0][0]*ecm[1][2])-(ecm[0][2]*ecm[1][0]))/A+0;
  x = (a/-2.0);
  y = (b/-2.0);
  r = sqrt(pow(x1-x,2)+pow(y1-y,2));
  printf("%.3f %.3f %.3f\n",x,y,r); //四捨五入は自動的にされる
 }
 return 0;
}