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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> paii;
typedef complex<double> P;

double ccw(P& p1, P& p2, P& p3)
{
	return ((p2.real() - p1.real())*(p3.imag() - p1.imag()) 
				- (p2.imag() - p1.imag())*(p3.real() - p1.real())) > 0;
}// ccw>0 ...ccw, ccw=0 ...colinear, ccw<0 ...cw

int main()
{
	int n;
	cin >> n;
	
	while(n--)
	{
		double x1, x2, x3, y1, y2, 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 xp = (b1*c2-b2*c1)/(a1*b2-a2*b1);
		double yp = (c1*a2-c2*a1)/(a1*b2-a2*b1);
		double r = hypot((xp-x1), (yp-y1));
		
		cout.precision(3);
		printf("%.3f %.3f %.3f\n", xp,yp, r);
	}
	
	return 0;
}

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

typedef complex<double> P;
#define PI 3.14159265358979
#define EPS (1e-10)
#define X real()
#define Y imag()

class Triangle{
  private:
    P a, b, c;
    double edgeA, edgeB, edgeC;
    double angleA, angleB, angleC;
    
    double LawOfCosines(double a, double b, double c){
      return acos((b*b + c*c - a*a) / (2.0*b*c));
    }
    
    bool equal(double a, double b){
      return (abs(a - b) < EPS) ? true : false;
    }
  
  public:
    Triangle(P p1, P p2, P p3){
      a = p1; b = p2; c = p3;
      edgeB = abs(c - a);
      edgeC = abs(a - b);
      edgeA = abs(b - c);
      angleA = LawOfCosines(edgeA, edgeB, edgeC);
      angleB = LawOfCosines(edgeB, edgeC, edgeA);
      angleC = LawOfCosines(edgeC, edgeA, edgeB);
    }
    
    double circumscribedCircleRedius(){
      return (edgeA / sin(angleA) / 2.0);
    }
    
    double circumscribedCircleX(){
      double A = sin(2.0*angleA);
      double B = sin(2.0*angleB);
      double C = sin(2.0*angleC);
      return ((a.X*A + b.X*B + c.X*C) / (A + B + C));
    }
    
    double circumscribedCircleY(){
      double A = sin(2.0*angleA);
      double B = sin(2.0*angleB);
      double C = sin(2.0*angleC);
      return ((a.Y*A + b.Y*B + c.Y*C) / (A + B + C));
    }
};

int main(void){
  int n;
  double x1, x2, x3, y1, y2, y3;
  double r, xp, yp;

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    P a(x1, y1);
    P b(x2, y2);
    P c(x3, y3);
    Triangle Tr(a, b, c);
    r = Tr.circumscribedCircleRedius();
    xp = Tr.circumscribedCircleX();
    yp = Tr.circumscribedCircleY();
    printf("%.3lf %.3lf %.3lf\n", xp, yp, r);
  }
  return 0;
}

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

using namespace std;

double henkan(double r) {
	r *= 10000.0;
	if (((((int)r % 10000)% 1000) % 100) % 10 >= 5){
		r += 10.0;
		r /= 10000.0;
	} else {
		r /= 10000.0;
	}
	return r;
}

int main() {
	int n;
	cin >> n;
	double x1, y1, x2, y2, x3, y3;
	for (int i = 0; i < n; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double r;
		double sina;
		double cosa;
		double a = sqrt(pow(x3-x2,2)+pow(y3-y2,2));
		double b = sqrt(pow(x2-x1,2)+pow(y2-y1,2));
		double c = sqrt(pow(x3-x1,2)+pow(y3-y1,2));
		cosa = (b*b+c*c-a*a)/(2.0*b*c);
		sina = sqrt(1-cosa*cosa);
		r = a / (sina*2.0);
		double aa, bb;
		double x4, y4;
		double xx1, yy1, xx2, yy2;
		xx1 = (x1+x2)/2.0;
		xx2 = (x1+x3)/2.0;
		yy1 = (y1+y2)/2.0;
		yy2 = (y1+y3)/2.0;
		if (y1 == y2) {
			bb = - (x3-x1)/(y3-y1);
			x4 = xx1;
			y4 = bb*x4+yy2-bb*xx2;
		} else if (y1 == y3){
			aa = - (x2-x1)/(y2-y1);
			y4 = xx2;
			x4 = (y4-yy1+aa*xx1)/aa;
		} else {
			aa = - (x2-x1)/(y2-y1);
			bb = - (x3-x1)/(y3-y1);
			x4 = (aa*xx1-bb*xx2-yy1+yy2)/(aa-bb);
			y4 = aa*x4+yy1-aa*xx1;
		}
		x4 = henkan(x4);
		y4 = henkan(y4);
		r = henkan(r);
		printf("%.3f %.3f %.3f\n", x4, y4, r);
	}
	return 0;
}

C++: #include <stdio.h>
#include <math.h>
#define NOT_E 200

double cequal(double *a,double *b,double *c,double *aa,double *bb,double *cc);
double equal(double a,double b,double c,double aa,double bb,double cc);
double answer(double x1,double x2,double y1,double y2,double *a,double *b);
int swap(double *a,double *b);

int main(){
	int i,cnt;
	double x1,x2,x3,y1,y2,y3,xp,yp/*¦*/,a1,a2,b1,b2,xm1,ym1,xm2,ym2,r;
	
	scanf("%d",&cnt);
	for(i=0;i<cnt;i++){
		
		scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
		
		xp=equal(y1,y2,y3,x1,x2,x3);
		yp=equal(x1,x2,x3,y1,y2,y3);
		
		
		if (xp==NOT_E || yp==NOT_E){
			if(xp==NOT_E){
				cequal(&x1,&x2,&x3,&y1,&y2,&y3);
			}else if(yp==NOT_E){
				cequal(&y1,&y2,&y3,&x1,&x2,&x3);
			}
			answer(x3,x2,y3,y2,&a1,&b1);
			answer(x3,x1,y3,y1,&a2,&b2);
			xp=(b2-b1)/(a1-a2);
			yp=a1*xp+b1;
			
		}
		
		if(xp==x1){
			r=sqrt((xp-x1)*(xp-x1));
		}else if(yp==y2){
			r=sqrt((yp-y1)*(yp-y1));
		}else{
			r=sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));
		}
		
		printf("%.3f %.3f %.3f\n",xp,yp,r);

	}
	return 0;
}
			
			
			
			

double cequal(double *a,double *b,double *c,double *aa,double *bb,double *cc){	/*a1=a2,a3ÆÈéæ¤ÉÀÑÖ¦é*/
	if(*a==*b){
	}else if (*b==*c){
		swap(a,c);
		swap(aa,cc);
	}else if (*c==*a){
		swap(b,c);
		swap(bb,cc);
	}else{
		return NOT_E;
	}
	
	return (*a+*b)/2;
}


double equal(double a,double b,double c,double aa,double bb,double cc){	/*ÀÑÖ¦È¢*/
	if(a==b){
	}else if (b==c){
		swap(&a,&c);
		swap(&aa,&cc);
	}else if (c==a){
		swap(&b,&c);
		swap(&bb,&cc);
	}else{
		return NOT_E;
	}
	return (aa+bb)/2;
}



double answer(double x1,double x2,double y1,double y2,double *a,double *b){	/*(x1,y1)Æ(x2,y2)Ì¼ñªüy=ax+bÌa,bð|C^ÅÔ·*/
	double xm,ym;
	*a=(y2-y1)/(x1-x2);
	xm=(x2+x1)/2;
	ym=(x2+y1)/2;
	*b=ym-*a*xm;
	return 0;
}

int swap(double *a,double *b){
	double temp;
	temp=*a;
	*a=*b;
	*b=*a;
	return 0;
}
	/*
	a2=(y1-y3)/(x3-x1);
	xm2=(x1+x3)/2;
	ym2=(x1+y3)/2;
	b2=ym2-a3*xm2;*/

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

int main(){
	int n;
	double x1,y1,x2,y2,x3,y3,x1_2,x1_3,y1_2,y1_3,z1_2,z1_3,a,b,c,r;
	while(cin >> n){
		for(int i = 0;i < n;++i){
			cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
			z1_2 = (((x1 * x1) + (y1 * y1)) * -1) - (((x2 * x2) + (y2 * y2)) * -1);
			z1_3 = (((x1 * x1) + (y1 * y1)) * -1) - (((x3 * x3) + (y3 * y3)) * -1);
			x1_2 = x1 - x2;
			x1_3 = x1 - x3;
			y1_2 = y1 - y2;
			y1_3 = y1 - y3;
			a = ((y1_2 * z1_3) - (y1_3 * z1_2)) / ((y1_2 * x1_3) - (y1_3 * x1_2)) * -1;
			b = ((x1_2 * z1_3) - (x1_3 * z1_2)) / ((x1_2 * y1_3) - (x1_3 * y1_2)) * -1;
			c = ((x1 * x1) + (y1 * y1) + (a * x1) + (b * y1)) * -1;
			r = sqrt(c + (a * a) + (b * b));
			printf("%.3f %.3f %.3f\n",a / 2.0,b / 2.0,r);
		}
	}
	return 0;
}