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<math.h>
#include <vector>
#include<stdio.h>
using namespace std;

class Triangle{

public:
	double a, b, c,a2,b2,c2;
	double cosA, sinA,R,px,py;

	//con???????§???¢???????????§?¨?????±???????????¬?????¨????????¨????????¨?????°???\???????????????????????£?????????
	double con1, con2, con3,con4,con5,con6;


	Triangle(double x1,double y1,double x2,double y2,double x3,double y3);

	double Radius();
	double Px();
	double Py();

};


//Triangle????????????????????????
Triangle::Triangle(double x1, double y1, double x2, double y2, double x3, double y3){

	a2 = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1);
	b2 = (x3 - x1)*(x3 - x1) + (y3 - y1)*(y3 - y1);
	c2 = (x2 - x3)*(x2 - x3) + (y2 - y3)*(y2 - y3);

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


	
	cosA = (b2 + c2 - a2) / (2 * b*c);
	sinA = sqrt(1 - (cosA*cosA));

	R = a / (2 * sinA);

	//????????¬?????????????????§?¨?????±???????
	con1 = (y3 - y2)*(x1*x1) - (y3 - y1)*(x2*x2) + (y2-y1)*(x3*x3);
	con2 = (y3 - y1)*x2 - (y2 - y1)*x3 + (y2 - y3)*x1;
	con3 = (y1*y1)*(y3 - y2) + (y2*y2)*(y1 - y3) + (y3*y3)*(y2 - y1);

	//????????????con1+2px*con2+con3=0??¨??????
	px = (con3 - con1) / (2 * con2);


	con4 = (x3 - x2)*(y1*y1) - (x3 - x1)*(y2*y2) + (x2 - x1)*(y3*y3);
	con5 = (x3 - x1)*y2 - (x2 - x1)*y3 + (x2 - x3)*y1;
	con6 = (x1*x1)*(x3 - x2) + (x2*x2)*(x1 - x3) + (x3*x3)*(x2 - x1);

	py = (con6 - con4) / (2 * con5);


}


//?????\????????????Radius????±?????????¢??°
double Triangle::Radius(){

	R=round(R*1000)/1000;
	return R;
}

//px???????????¢??°
double Triangle::Px(){

	px = floor(px*1000)/1000;
	return px;
}

//py???????????¢??°
double Triangle::Py(){

	py = floor(py*1000) / 1000;
	return py;
}



//??£??????????????¨???????§£???
int main(void){


	int n;
	double x1, x2, x3, y1, y2, y3;
	cin >> n;

	for (int i = 0; i < n; i++){
	
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
	
		//????§???¢??????????????????????????§???????????????
		Triangle Triangle(x1, y1, x2, y2, x3, y3);
		
		printf("%.3f ", Triangle.Px());
		printf("%.3f ", Triangle.Py());
		printf("%.3f\n",Triangle.Radius());


	}


	return 0;
}

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

double heronsMethod(double a, double b, double c){
	double s = (a + b + c) / 2;
	return sqrt(s * (s - a) * (s - b) * (s - c));
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		double x1, x2, x3, y1, y2, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double a = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
		double b = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
		double c = sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
		double s = heronsMethod(a, b, c);
		double x = (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);
		double y = (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);
		double r = (a * b * c) / sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));
		printf("%.3f %.3f %.3f\n", x, y, r);
	}
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	complex<double> Ans;
	complex<double> P[3];
	for(int i=0;i<3;i++){
		cin>> P[i].real()>> P[i].imag();
	}
	complex<double> T[2];
	complex<double> K[2];
	double katamuki[2];
	for(int i=0;i<2;i++){
		T[i].real() = (P[i].real() + P[i+1].real()) / 2;
		T[i].imag() = (P[i].imag() + P[i+1].imag()) / 2;
		complex<double> N;
		N = (P[i+1]-P[i])/abs(P[i+1]-P[i]);
		K[i].real() =  N.imag();
		K[i].imag() = -N.real();
	}
	int a = (T[1]-T[0]).real();
	int b = (T[1]-T[0]).imag();
	int x0 = K[0].real();
	int y0 = K[0].imag();
	int x1 = K[1].real();
	int y1 = K[1].imag();
	int m = ( a * y0 - b * x0 ) / ( x0 * y1 - x1 * y0);
	K[1] *= m;
	Ans = K[1] + T[1];


	printf("%.3f %.3f %.3f", Ans.real(), Ans.imag(), abs(Ans-P[0]));
	printf("\n");
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(3);
	int n;
	cin>> n;
	for(int i=0;i<n;i++){
		solve();
	}
	return 0;
}

C++: #include<complex>
#include<stdio.h>
#define F(a,b,c) acos((b*b+c*c-a*a)/2/b/c)
int main(){int n;float d,e,f,g,h,i;for(scanf("%d",&n);n--;){scanf("%f%f%f%f%f%f",&d,&g,&e,&h,&f,&i);std::complex<double> a(d,g),b(e,h),c(f,i);float A=abs(b-c),B=abs(c-a),C=abs(a-b),L=F(A,B,C),s=sin(2*L),t=sin(2*F(B,C,A)),u=sin(2*F(C,A,B)),v=s+t+u;printf("%.3f %.3f %.3f\n",(d*s+e*t+f*u)/v,(g*s+h*t+i*u)/v,A/sin(L)/2);}}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<string>
using namespace std;


int main(){

  int n;
  cin >> n;
  double x[3];

  double y[3];

  for(int i=0; i<n; i++){
    cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];

    double a, b, c;
    double r, px, py;

    a = sqrt( (x[0]-x[1])*(x[0]-x[1]) + (y[0]-y[1])*(y[0]-y[1]) );
    b = sqrt( (x[1]-x[2])*(x[1]-x[2]) + (y[1]-y[2])*(y[1]-y[2]) );
    c = sqrt( (x[2]-x[0])*(x[2]-x[0]) + (y[2]-y[0])*(y[2]-y[0]) );

    r = (a*b*c) / (sqrt((a+b+c)*(b+c-a)*(a-b+c)*(a+b-c)));
    px = (((x[0]*x[0])+(y[0]*y[0]))*(y[1]-y[2])+((x[1]*x[1])+(y[1]*y[1]))*(y[2]-y[0])
    +((x[2]*x[2])+(y[2]*y[2]))*(y[0]-y[1]))/(x[0]*(y[1]-y[2])+x[1]*(y[2]-y[0])+x[2]*(y[0]-y[1]))/2;

    py = (((x[0]*x[0])+(y[0]*y[0]))*(x[1]-x[2])+((x[1]*x[1])+(y[1]*y[1]))*(x[2]-x[0])
    +((x[2]*x[2])+(y[2]*y[2]))*(x[0]-x[1]))/(y[0]*(x[1]-x[2])+y[1]*(x[2]-x[0])+y[2]*(x[0]-x[1]))/2;


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




  return 0;
}














// EOF

C++: #include <iostream>
#include <complex>
#include <cstdio>
using namespace std;
typedef complex<double> P;

double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
P outcircle(P a,P b,P c){
  return (norm(b-c)*(norm(c-a)+norm(a-b)-norm(b-c))*a+
	  norm(c-a)*(norm(a-b)+norm(b-c)-norm(c-a))*b+
	  norm(a-b)*(norm(b-c)+norm(c-a)-norm(a-b))*c)/(P)(4*cross(b-a,c-a)*cross(b-a,c-a));
}
int main(){
  int n;
  double x1,y1,x2,y2,x3,y3;
  P a,b,c;
  cin>>n;
  for(;n>0;n--){
    cin >>x1 >>y1 >>x2 >>y2 >>x3 >>y3;
    P a=P(x1,y1);
    P b=P(x2,y2);
    P c=P(x3,y3);
    P q = outcircle(a,b,c);
    printf("%.3f %.3f %.3f\n",q.real(),q.imag(),abs(a-q));
  }
  return 0;
}

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

int main(){
	double x1, y1, x2, y2, x3, y3;
	int n;
	double p, q, r;//円の中心を(p, q)、半径をrとする
	
	scanf("%d", &n);
	
	while(n--){
		scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
		
		p = ((pow(x1,2)-pow(x2,2))*(y2-y3)-(pow(x2,2)-pow(x3,2))*(y1-y2)-(y1-y2)*(y2-y3)*(y3-y1)) / (2*((x1-x2)*(y2-y3)-(x2-x3)*(y1-y2)));
		q = ((pow(y1,2)-pow(y2,2))*(x2-x3)-(pow(y2,2)-pow(y3,2))*(x1-x2)-(x1-x2)*(x2-x3)*(x3-x1)) / (2*((y1-y2)*(x2-x3)-(y2-y3)*(x1-x2)));
		r = sqrt(pow(x1-p,2)+pow(y1-q,2));
		
		//p += 0.0005; q += 0.0005; r += 0.0005;
		
		printf("%.3f %.3f %.3f\n", p, q, r);
	}
	return 0;
}