Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var num int
	fmt.Scan(&num)
	for i := 0; i < num; i++ {
		var x1, y1, x2, y2, x3, y3 float64
		fmt.Scanf("%f%f%f%f%f%f", &x1, &y1, &x2, &y2, &x3, &y3)

		a := 2 * (x2 - x1)
		b := 2 * (y2 - y1)
		c := 2 * (x3 - x1)
		d := 2 * (y3 - y1)
		e := x2*x2 - x1*x1 + y2*y2 - y1*y1
		f := x3*x3 - x1*x1 + y3*y3 - y1*y1

		// 直線1: ax + by - e = 0
		// 直線2: cx + dy - f = 0
		px := (d*e - b*f) / (a*d - b*c)
		py := (c*e - a*f) / (b*c - a*d)
		r := math.Sqrt((px-x1)*(px-x1) + (py-y1)*(py-y1))
		fmt.Printf("%.3f %.3f %.3f\n", px, py, r)
	}
}

C++: // 2014/07/14 Tazoe

#include <iostream>
#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 a1 = 2*(x2-x1);
		double b1 = 2*(y2-y1);
		double c1 = x1*x1-x2*x2+y1*y1-y2*y2;

		double a2 = 2*(x3-x1);
		double b2 = 2*(y3-y1);
		double c2 = x1*x1-x3*x3+y1*y1-y3*y3;

		double px = (b1*c2-b2*c1)/(a1*b2-a2*b1);
		double py = (c1*a2-c2*a1)/(a1*b2-a2*b1);

		double r = sqrt((px-x1)*(px-x1)+(py-y1)*(py-y1));

		cout.precision(3);
		cout << fixed << px << ' ' << fixed << py << ' ' << fixed << r << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
long double ff(long double a){
  
  a*=10000.0;
  //  cout<<a<<endl;
  int c = a;
  if(c%10>4)c+=10;
  c/=10;
  return (long double)c/1000.0;
}



long double ax,ay,bx,by,cx,cy,ox,oy,dx,dy,ex,ey;
//ack はACの傾き  eos はEOの切片
long double abk,ack,dok,eok,eos,dos,eps=0.0;
int n;
int main(){
  // cout<<ff(999.9999)<<endl;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>ax>>ay>>bx>>by>>cx>>cy;
    //ABの中点をD,  ACの中点をE 外接円の中心をO とする
    dx=(ax+bx)/2.0;
    dy=(ay+by)/2.0;
    ex=(ax+cx)/2.0;
    ey=(ay+cy)/2.0;
    
    if(ax==bx){
      abk=(ay-by)/0.000000000001;
    }else{
      abk=(ay-by)/(ax-bx);
    }
    if(abk==0.0)abk=0.000000000001;
    dok=-1.0/abk;
    dos=dy-dx*dok;
    
    
    if(ax==cx){
      ack=(ay-cy)/0.000000000001;
    }else{
      ack=(ay-cy)/(ax-cx);
    }
    if(ack==0.0)ack=0.000000000001;
    eok=-1.0/ack;
    eos=ey-ex*eok;
    
    //Y  =  dok X  + dos
    //Y  =  eok X  + eos
    //dok X + dos = eok X + eos
    
    long double Y,X;
    if(dok-eok==0.0){
      X=(eos-dos)/0.000000000001;
    }else{
      X=(eos-dos)/(dok-eok);
    }
    Y= dok * X + dos;
    
    printf("%.3Lf %.3Lf ",ff(X),ff(Y));
    //cout<<ax<<' '<<X<<' '<<ay<<' '<<Y<<endl;
    printf("%.3Lf\n" ,  ff( sqrt( pow(ax-X,2) + pow(ay-Y,2) )));

    
    
  }
  return 0;
}

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

using namespace std;

int main() {
	double x1, y1, x2, y2, x3, y3;
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double x = ((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));
		double y = ((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));

		printf("%.3f %.3f %.3f\n", x, y, sqrt(pow((x1 - x), 2) + pow((y1 - y), 2)));
	}
	return 0;
}

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

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
	int n;
	double x1,x2,x3,y1,y2,y3;
	double a1,a2,b1,b2,c1,c2;
	double px,py;

	cin >> n;
	while(n > 0){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		n--;
	}
	
	a1 = 2 * (x2 - x1);
	b1 = 2 * (y2 - y1);
	c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
	a2 = 2 * (x3 - x1);
	b2 = 2 * (y3 - y1);
	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);
	
	cout << fixed << setprecision(3) << px << " " << fixed << setprecision(3) << py << " " << fixed << setprecision(3) << hypot(px - x1, py - y1) << endl;

	return 0;
}

C++: //#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>

using namespace std;


int main(){

	int n;
	double ax, ay, bx, by, cx, cy;
	double A, B, C,S2;
	double x, y,r;

	cin >> n;

	while (n--){
		cin >> ax >> ay >> bx >> by >> cx >> cy;

		A = (bx - cx)*(bx - cx) + (by - cy)*(by - cy);
		B = (cx - ax)*(cx - ax) + (cy - ay)*(cy - ay);
		C = (bx - ax)*(bx - ax) + (by - ay)*(by - ay);
		S2 = A*(B + C - A) + B*(C + A - B) + C*(A + B - C);

		x = (A*(B + C - A)*ax + B*(C + A - B)*bx + C*(A + B - C)*cx) / S2;
		y = (A*(B + C - A)*ay + B*(C + A - B)*by + C*(A + B - C)*cy) / S2;

		r = sqrt((x - ax)*(x - ax) + (y - ay)*(y - ay));

		printf("%.3f %.3f %.3f\n", x, y, r);
	}
}

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

using namespace std;

int main(void){
	int num;
	cin >> num;
	vector<double> res_x, res_y, res_r;
	for (int i=1; i<=num; ++i){
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double e1_2 = sqrt(pow((x2-x1), 2) + pow((y2-y1), 2));
		double e2_3 = sqrt(pow((x2-x3), 2) + pow((y2-y3), 2));
		double e3_1 = sqrt(pow((x3-x1), 2) + pow((y3-y1), 2));
		double theta = acos((e1_2*e1_2 + e2_3*e2_3 - e3_1*e3_1) / (2*e1_2*e2_3));
		//正弦定理により
		double r = e3_1 / (2*sin(theta));
		double a1 = 2*(x2-x1);
		double b1 = 2*(y2-y1);
		double c1 = x1*x1 - x2*x2 + y1*y1 -y2*y2;
		double a2 = 2*(x3-x1);
		double b2 = 2*(y3-y1);
		double c2 = x1*x1 - x3*x3 + y1*y1 - y3*y3;
		double x = (b1*x2 - b2*c1) / (a1*b2 - a2*b1);
		double y = (c1*a2 - c2*a1) / (a1*b2 - a2*b1);
		res_x.push_back(x);
		res_y.push_back(y);
		res_r.push_back(r);
	}
	for (int i=0; i<num; ++i){
		cout << fixed << setprecision(3) << res_x[i] << " " << res_y[i] << " " << res_r[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>

using namespace std;

int main()
{

	int n;
	double a,b,c,d,e,f,x1,x2,x3,y1,y2,y3;
	double ans_x,ans_y,ans_r;

	cin>>n;

	for(int i=0;i<n;i++){

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


		if(y1==y2){
			ans_x=(x1+x2)/2.0;
			a=-(x3-x2)/(y3-y2);
			b=(x2+x3)/2.0; c=(y2+y3)/2.0;
		}else if(y2==y3){
			ans_x=(x2+x3)/2.0;
			a=-(x2-x1)/(y2-y1);
			b=(x1+x2)/2.0; c=(y1+y2)/2.0;
		}else{
			a=-(x3-x2)/(y3-y2);
			b=(x2+x3)/2.0; c=(y2+y3)/2.0;
			d=-(x2-x1)/(y2-y1);
			e=(x1+x2)/2.0; f=(y1+y2)/2.0;
			
			ans_x=(a*b-d*e-c+f);
		}

		ans_y=a*(ans_x-b)+c;
		ans_r=sqrt( (x1-ans_x)*(x1-ans_x) + (y1-ans_y)*(y1-ans_y) );

		printf("%.3f %.3f %.3f\n",ans_x,ans_y,ans_r);

	}

	return 0;

}