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>

#define SQ(x) ((x) * (x))

int main(void)
{
    int n;
    double x1, x2, x3, y1, y2, y3;
    double a, b, c, d, e, f;
    double l, m, n;
    
    cin >> n;
    for (int i = 0; i < n; i++){
        scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
        
        a = (x1 - x2);
        b = (y1 - y2);
        c = -1 * (SQ(x1) - SQ(x2) + SQ(y1) - SQ(y2));
        d = (x1 - x3);
        e = (y1 - y3);
        f = -1 * (SQ(x1) - SQ(x3) + SQ(y1) - SQ(y3));
        
        l = (c * e - b * f) / (e * a - b * d);
        m = (d * c - a * f) / (d * b - e * a);
        
        n = -1 * (SQ(x1) + SQ(y1) + l * x1 + m * y1);
        
        printf("%.3f %.3f %.3f\n", l / -2.0, m / -2.0, sqrt(SQ(l) + SQ(m) - 4 * n) / 2.0);
    }
    
    return (0);
}

C++: #include <stdio.h>
#include <math.h>

int main(void){
	int n, i, j;
	double x1,y1,x2,y2,x3,y3, px, py;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
		py = ((x3 - x1) * (pow(x2,2.0) - pow(x1,2.0) + pow(y2,2.0) - pow(y1,2.0)) - (x2 - x1) * (pow(x3,2.0) - pow(x1,2.0) + pow(y3,2.0) - pow(y1,2.0))) / (2 * ((y2 - y1) * (x3 - x1) - (y3 - y1) * (x2 - x1)));
		px = ((y3 - y1) * (pow(y2,2.0) - pow(y1,2.0) + pow(x2,2.0) - pow(x1,2.0)) - (y2 - y1) * (pow(y3,2.0) - pow(y1,2.0) + pow(x3,2.0) - pow(x1,2.0))) / (2 * ((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)));
		printf("%f %f %f\n",px,py,sqrt(pow(px - x1,2.0) + pow(py - y1,2.0)));
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
   int n;
   double x[10], y[10], p, q, 
   p1, p2, p3, p4, p5, p6, p7, p8, q1, q2, q3, q4, q5, q6, q7;
   scanf("%d", &n);
   while ( n ) {
       scanf("%lf %lf %lf %lf %lf %lf", &x[1], &y[1], &x[2], &y[2], &x[3], &y[3]);
       p1 = x[2] * x[2] + y[2] * y[2] - x[3] * x[3] - y[3] * y[3];
       p2 = 2 * y[2] - 2 * y[3];
       p3 = y[1] * y[1] + x[1] * x[1] - x[2] * x[2] - y[2] * y[2];
       p4 = 2 * y[1] - 2 * y[2];
       p5 = -2 * x[1] + 2 * x[2];
       p6 = 2 * y[1] - 2 * y[2];
       p7 = -2 * x[2] + 2 * x[3];
       p8 = 2 * y[2] - 2 * y[3];
       p = ( p1 / p2 - p3 / p4 ) / ( p5 / p6 - p7 / p8 );
       printf("%lf %lf %lf %lf %lf %lf %lf %lf\n", p1, p2, p3, p4, p5, p6, p7, p8);
   }
   return 0;
}

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

double length(double x1, double y1, double x2, double y2){
	double x = x1 - x2;
	double y = y1 - y2;
	return sqrt(x*x + y*y);
}

int main(){
	int n, i;
	double x1, x2, x3, y1, y2, y3;
	double r, xp, yp, a, b, c, S;
	cin >> n;
	for(i=0; i<n; i++){
		cin >> x1 >> y1 >> x2 >>  y2 >> x3 >> y3;

		a = length(x1, y1, x2, y2);
		b = length(x2, y2, x3, y3);
		c = length(x3, y3, x1, y1);

		r = a*b*c/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
		S = a*b*c/(4*r);
		xp = ((a*a)*(b*b + c*c - a*a)*x3+(b*b)*(c*c + a*a - b*b)*x1+(c*c)*(a*a + b*b - c*c)*x2)/(16*S*S); 
		yp = ((a*a)*(b*b + c*c - a*a)*y3+(b*b)*(c*c + a*a - b*b)*y1+(c*c)*(a*a + b*b - c*c)*y2)/(16*S*S); 

		printf("%.3f %.3f %.3f", xp, yp, r);
	}

	return 0;
}

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

using namespace std;

typedef complex<double> Point;

bool eqv(double d1, double d2) {
    return abs(d1-d2) < 1e-10;
}

double r_(double x) {
    if(abs(x) < 0.001) return 0;
    return x;
}

int main() {
    int N;

    cin >> N;
    while(N--) {
        double x1, x2, x3, y1, y2, y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Point p1(x1, y1), p2(x2, y2), p3(x3, y3);

        //³·è
        double R = abs(abs(p3-p2) / sin(arg(p2-p1) - arg(p3-p1))) / 2;

        Point vb = p3-p2;
        double len = sqrt(R*R - norm(vb)/4.0);
        Point vbh = vb * Point(0, 1);
        Point center = p1 + vb/2.0 + vbh*len/abs(vbh);
        if(eqv(abs(center-p1), R) && eqv(abs(center-p2), R) && eqv(abs(center-p3), R)) {}
        else center = p1 + vb/2.0 - vbh*len/abs(vbh);
        printf("%.3f %.3f %.3f\n", r_(center.real()), r_(center.imag()), r_(R));
    }
    return 0;
}

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

using namespace std;

int main() {
    int n;

    scanf("%d", &n);

    double x1, y1, x2, y2, x3, y3;

    while (n--) {
        scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
 
        if (y1 == y3) {
            swap(x3, x2);
            swap(y3, y2);
        }

        if (y2 == y3) {
            swap(x3, x1);
            swap(y3, y1);
        }

        double a = x2 - x3;
        double b = y2 - y3;
        double c = x2 + x3;
        double d = y2 + y3;
        double e = x3 - x1;
        double f = y3 - y1;
        double g = x3 + x1;
        double h = y3 + y1;

        double px = ((a / b) * (c / 2) + d / 2 - (e / f) * (g / 2) - h / 2) / (a / b - e / f);
        double py = -(a / b) * px + (a / b) * c / 2 + d / 2;
        double x = x1 - px;
        double y = y1 - py;
        double r = sqrt(x * x + y * y);

        printf("%.3lf %.3lf %.3lf\n", px, py, r);
    }

    return 0;
}

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

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;
		double c1 = (x1 + x2) / 2;
		double c2 = (x1 + x3) / 2;
		double d1 = (y1 + y2) / 2;
		double d2 = (y1 + y3) / 2;
		double k1 = (y2 - y1) / (x2 - x1);
		double k2 = (y3 - y1) / (x3 - x1);
		double py = (c2 - c1 + k2 * d2 - k1 * d1) / (k2 - k1);
		double px = k1 * (d1 - py) + c1;
		double r = sqrt((px - x1)*(px - x1) + (py - y1)*(py - y1));
		cout << setprecision(3);
		cout << fixed;
		cout << px << " " << py << " " << r << endl;
	}
	return 0;
}

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

using namespace std;

int main(void){
	int n;
	double x1,y1,x2,y2,x3,y3,m1,m2,x,y,r;
	double xa,ya,xb,yb,xc,yc;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>xa>>ya>>xb>>yb>>xc>>yc;
		if(yb==ya){
			x1=xa; y1=ya;
			x2=xc; y2=yc;
			x3=xb; y3=yb;
		} else if(yc==yb){
			x1=xc; y1=yc;
			x2=xa; y2=ya;
			x3=xb; y3=yb;
		} else {
			x1=xc; y1=yc;
			x2=xb; y2=yb;
			x3=xa; y3=ya;
		}
		m1=(x2-x1)/(y2-y1);
		m2=(x3-x2)/(y3-y2);
		x=(1/(m2-m1))*(y3-y1)+(x1+x2)/2*m1-(x2+x3)/2*m2;
		y=(x-(x1+x2)/2)*m1+(y1+y2)/2;
		r=sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y));
		printf("%.3f %.3f %.3f\n",x,y,r);
	}
}

C++: #include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;

int sosuu(int n);

int main(){
    double x[3]={0};
    double y[3]={0};
    int i=0;
    scanf("%d",&i);
    while(scanf("%lf",&x[0])!=EOF){
        scanf("%lf",&y[0]);
        scanf("%lf",&x[1]);
        scanf("%lf",&y[1]);
        scanf("%lf",&x[2]);
        scanf("%lf",&y[2]);
        
        double a1= 2*(x[1]-x[0]);
        double b1= 2*(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*(x[2]-x[0]);
        double b2= 2*(y[2]-y[0]);
        double c2= x[0]*x[0]-x[2]*x[2]+y[0]*y[0]-y[2]*y[2];
        
        double xa = (b1*c2-b2*c1)/(a1*b2-a2*b1);
        double ya = (c1*a2-c2*a1)/(a1*b2-a2*b1);
        
        double r =sqrt((xa-x[0])*(xa-x[0])+(ya-y[0])*(ya-y[0]));
        
        printf("%.3lf %.3lf %.3lf\n",xa,ya,r);
        
    }
    
}