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 <iostream>
#include <cmath>
#include <cstdio>

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

		double const a = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));	
		double const b = sqrt((x3-x2)*(x3-x2) + (y3-y2)*(y3-y2));
		double const c = sqrt((x3-x1)*(x3-x1) + (y3-y1)*(y3-y1));

		double const cosA = (b*b+c*c-a*a)/(2*b*c);
		double const cosB = (a*a+c*c-b*b)/(2*a*c);
		double const cosC = (a*a+b*b-c*c)/(2*a*b);
		double const sinA = sqrt(1-cosA*cosA);

		double const r = a / (sinA * 2);
		//std::cout << "r = " << r << std::endl;

		//std::cout << "cosA = " << cosA << std::endl;
		//std::cout << "cosB = " << cosB << std::endl;
		//std::cout << "cosC = " << cosC << std::endl;

		if(-0.001 < cosA && cosA < 0.001) std::printf("%.3lf %.3lf", (x1+x2) / 2 , (y1+y2) / 2);
		else if (-0.001 < cosB && cosB < 0.001) std::printf("%.3lf %.3lf", (x2+x3) / 2 ,(y2+y3) / 2);
		else if (-0.001 < cosC && cosC < 0.001) std::printf("%.3lf %.3lf", (x1+x3) / 2 , (y1+y3) / 2);
		else
		{
			double const h = sqrt(r*r-(c/2)*(c/2));
				
			//std::cout << "c = " << c << std::endl;
			std::cout << "h = " << h << std::endl;
			
			double const xm = (x1+x3)/2;
			double const ym = (y1+y3)/2;
			std::cout << "xm = " << xm << " ym = " << ym << std::endl;

			double const sinD = (y1-y3) / sqrt((x3-x1)*(x3-x1) + (y3-y1)*(y3-y1));
			double const cosD = (x1-x3) / sqrt((x3-x1)*(x3-x1) + (y3-y1)*(y3-y1));
			std::cout << "sinD = " << sinD << " cosD = " << cosD << std::endl;

			double y4 = h * cosD;
			double x4 = h * sinD;
			std::cout << "x4 = " << x4 << " y4 = " << y4 << std::endl;

			if((sinD < 0 && cosD < 0) || (sinD > 0 && cosD < 0)) x4 *= -1;
			if((sinD == 0 && cosD < 0) || (sinD > 0 && cosD > 0) || (sinD < 0 && cosD > 0)) y4 *= -1;

			double const xd = xm + x4;
			double const yd = ym + y4;


			std::cout << xd << " " << yd;
		}
		std::printf(" %.3lf\n", r);
	}
	return 0;
}

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

int N;
double X1,Y1,X2,Y2,X3,Y3;

int main()
{
    scanf("%d",&N);
    while (N--)
    {
        scanf("%lf%lf%lf%lf%lf%lf",&X1,&Y1,&X2,&Y2,&X3,&Y3);
        double a = X1-X2;
        double b = Y1-Y2;
        double c = -(X1*X1+Y1*Y1-X2*X2-Y2*Y2);
        double d = X2-X3;
        double e = Y2-Y3;
        double f = -(X2*X2+Y2*Y2-X3*X3-Y3*Y3);
        double l = (c*e-b*f)/(a*e-b*d);
        double m = (d*c-a*f)/(d*b-e*a);
        double n = -(X1*X1+Y1*Y1+l*X1+m*Y1);
        printf("%.3f %.3f %.3f\n",l*-0.5,m*-0.5,sqrt(l*l+m*m-n*4.0)/2.0);
    }
}

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

double a,b,c,d,e,f,x,y,r;
int n;

double ifof(double a){
	int n = a*10000;
	if(n%10 >= 5)
		n+=10;
	else if(n%10 <= -5)
		n-=10;
	return n/10000.0;
}

double solvex(){
	double k,l;
	k = (c*c)-(a*a)+(d*d)-(b*b)-(2*y*(d-b));
	l = 2*(c-a);
	return k/l;
}

double solvey(){
	double k,l;
	k = ((e-a)*((c*c)-(a*a)+(d*d)-(b*b)))-((c-a)*((e*e)-(a*a)+(f*f)-(b*b)));
	l = 2*(((d-b)*(e-a))-((f-b)*(c-a)));
	return k/l;
}

int main(){
	std::cin >> n;
	for(int i=0; i<n; i++){
		std::cin >> a >> b >> c >> d >> e >> f;
		y = solvey();
		x = solvex();
		r = std::sqrt(((x-a)*(x-a)) + ((y-b)*(y-b)));
		std::printf("%.3f %.3f %.3f\n",ifof(x),ifof(y),ifof(r));
	}
	return 0;
}

C++: //04
#include<iostream>
#include<complex>
#include<iomanip>
#include<cmath>

#define S(X) ((X)*(X))

using namespace std;

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    complex<double> p[3];
    for(int j=0;j<3;j++){
      double x,y;
      cin>>x>>y;
      p[j]=complex<double>(x,y);
    }
    double d[3];
    for(int j=0;j<3;j++){
      d[j]=abs(p[j]-p[(j+1)%3]);
    }
    double r=d[0]/2/sqrt(1-S((S(d[1])+S(d[2])-S(d[0]))/2/d[1]/d[2]));
    complex<double> c=p[0]+polar(r,arg(p[1]-p[0])+acos(d[1]/2/r));
    cout<<fixed<<setprecision(3)<<c.real()<<' '<<c.imag()<<' '<<r<<endl;
  }
  return 0;
}

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

int main() {
  int n;
  double x1,y1,x2,y2,x3,y3,p,p1,p2,q,q1,q2,r;
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    p1 = (x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1) * (y3 - y1) - (x3 * x3 - x1 * x1 + y3 * y3 - y1 * y1) * (y2 - y1);
    p2 = 2 * (x1 * y2 - x1 * y3 + x2 * y3 - x2 * y1 + x3 * y1 - x3 * y2);
    p = p1 / p2;
    q1 = (y2 * y2 - y1 * y1 + x2 * x2 - x1 * x1) * (x3 - x1) - (y3 * y3 - y1 * y1 + x3 * x3 - x1 * x1) * (x2 - x1);
    q2 =  2 * (y1 * x2 - y1 * x3 + y2 * x3 - y2 * x1 + y3 * x1 - y3 * x2);
    q = q1 / q2;
    r = sqrt((x1-p) * (x1-p) + (y1-q) * (y1-q) );
    p *= 1000;
    p += 0.5;
    p = floor(p);
    p /= 1000;
    q *= 1000;
    q += 0.5;
    q = floor(q);
    q /= 1000;
    r *= 1000;
    r += 0.5;
    r = floor(r);
    r /= 1000;
    printf("%.3f %.3f %.3f\n", p, q, r);
  }
}

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

using namespace std;

int main() {
    int n, x1, y1, x2, y2, x3, y3;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        double a1 = 2 * (x2 - x1), a2 = 2 * (x3 - x1),
               b1 = 2 * (y2 - y1), b2 = 2 * (y3 - y1),
               c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2,
               c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3,
               px = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1),
               py = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1),
               r = sqrt(pow(x1 - px, 2) + pow(y1 - py, 2));
        printf("%.3f %.3f %.3f\n", px, py, r);
    }
    return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
struct Point{double x,y;};
double dis(Point a,Point b){
  return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
Point tri(Point a, Point b, Point c){
  double a1,a2,b1,b2,c1,c2;
  a1=2*(b.x-a.x);
  b1=2*(b.y-a.y);
  c1=a.x*a.x-b.x*b.x+a.y*a.y-b.y*b.y;
  a2=2*(c.x-a.x);
  b2=2*(c.y-a.y);
  c2=a.x*a.x-c.x*c.x+a.y*a.y-c.y*c.y;
  Point p;
  p.x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
  p.y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
  return p;
}
int main(){
  int n;cin >> n;int i;
  for(i=0;i<n;i++){
  Point a,b,c;cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
  Point x = tri(a,b,c);
  printf("%.3f %.3f %.3f\n",x.x,x.y,dis(x,a));
  }
}

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

int main() {
	int num;
	double x1,y1,x2,y2,x3,y3,px,py,r;
	cin>>num;
	while(num--){
		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(pow((x1-px),2.0)+pow((y1-py),2.0));
		printf("%.3f %.3f %.3f\n",px,py,r);
	}	
	return 0;
}

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

int main(void)
{
double  x1,x2,x3,y1,y2,y3,x,y ,r ,a   ;

while(scanf("%lf%lf%lf%lf%lf%lf",&x1,&x2,&x3,&y1,&y2,&y3)!=EOF){
a=(x1*x1+x2*x2-x3*x3)/2*x1*x2;
r=x3/(2*sin(double a));