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 <bits/stdc++.h>

using namespace std;

#define EPS (1e-10)

struct Point {
    double x, y;

    Point(){}
    Point(double x, double y) : x(x), y(y) {}

    Point operator + (const Point &p) const {
        return Point(x + p.x, y + p.y);
    }

    Point operator - (const Point &p) const {
        return Point(x - p.x, y - p.y);
    }
    
    Point operator * (const double &k) const {
        return Point(x * k, y * k);
    }
};

double dot(const Point &a, const Point &b)
{
    return a.x * b.x + a.y * b.y;
}

double norm(const Point &p)
{
    return dot(p, p);
} 

double abs(const Point &p)
{
    return sqrt(norm(p));
}

typedef vector<Point> Polygon;

struct Circle {
    Point p;
    double r;
    Circle(){}
    Circle(Point p, double r) : p(p), r(r) {}
};

Circle smallest_enclosing_circle(const Polygon &pg)
{    
    Point p(0, 0);
    int N = pg.size();
    for (int i = 0; i < (int)pg.size(); i++) {
	p = p + pg[i];
    }
    p = p * (1. / pg.size());
    double d = 0.5;
    for (int k = 1; k <= 30; k++) {
	for (int i = 0; i < 100; i++) {
	    int s = 0;
	    for (int j = 0; j < N; j++) {
		if (abs(pg[j] - p) > abs(pg[s] - p)) {
		    s = j;
		}
	    }
	    p = p + (pg[s] - p) * d;
	}
	d *= 0.5;
    }
    double r = 0;
    for (int i = 0; i < N; i++) {
	if (abs(pg[i] - p) > r) {
	    r = abs(pg[i] - p);
	}
    }
    return Circle(p, r);
}

double round(double x)
{
    x *= 1000;
    x = x + (x >= 0 ? 0.5 : -0.5);
    x = (int)x;
    return x / 1000;
}

int main()
{
    Polygon pg(3);
    int N;
    cin >> N;
    while (N--) {
        for (int i = 0; i < 3; i++) {
            cin >> pg[i].x >> pg[i].y;
        }
        auto c = smallest_enclosing_circle(pg);
        printf("%.3f %.3f %.3f\n", round(c.p.x), round(c.p.y), round(c.r));
    }
    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.00000001;
    }else{
      abk=(ay-by)/(ax-bx);
    }
    if(abk==0.0)abk=0.00000001;
    dok=-1.0/abk;
    dos=dy-dx*dok;
    
    
    if(ax==cx){
      ack=(ay-cy)/0.00000001;
    }else{
      ack=(ay-cy)/(ax-cx);
    }
    if(ack==0.0)ack=0.00000001;
    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.00000001;
    }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 <cstdio>
#include <cctype>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <complex>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef complex<double> P;
const double PI = 3.141592653589793238462643383279502884L;
const int LARGE_PRIME = 1000000007;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i,a,cont,next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i,a,b,step) repfn(i, a, i < b, i + step)
#define repab(i,a,b) repby(i, (a), (b), 1)
#define rep(i,n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  int n;
  double x, y;
  cin >> n;

  while (n--) {
    cin >> x >> y;
    P p(x, y);
    cin >> x >> y;
    P q(x, y);
    cin >> x >> y;
    P r(x, y);

    double eA = norm(q - r);
    double eB = norm(r - p);
    double eC = norm(p - q);

    P c = (eA*(eB+eC-eA)*p + eB*(eC+eA-eB)*q + eC*(eA+eB-eC)*r)
          / (eA*(eB+eC-eA) + eB*(eC+eA-eB) + eC*(eA+eB-eC));

    printf("%.3f %.3f %.3f\n", c.real(), c.imag(), abs(p - c));

  }
  return 0;
}

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

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define SQ(i) ((i) * (i))
using namespace std;

int main(){
  double x1, y1, x2, y2, x3, y3;
  double a1, b1, c1, a2, b2, c2, x, y, a, b, c, cos_a, sin_a, r;
  int n;
  scanf("%d", &n);
  while(n--){
    scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
    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;
    x = (b1 * c1 - b2 * c1) / (a1 * b2 - a2 * b1);
    y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);

    r = SQ(x3-x) + SQ(y3 - y);
    r = sqrt(r);
    printf("%.3f %.3f %.3f\n",x, y, r);
  }
  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=xb; y1=yb;
			x2=xc; y2=yc;
			x3=xa; y3=ya;
		} else if(yc==yb){
			x1=xb; y1=yb;
			x2=xa; y2=ya;
			x3=xc; y3=yc;
		} else {
			x1=xa; y1=ya;
			x2=xb; y2=yb;
			x3=xc; y3=yc;
		}
		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 <iostream>
#include <cmath>
#include <stdio.h>

using namespace std;

struct point{
     double x, y;
};

void renritu(point p1, point p2, double *a, double *b, double *c){
    *a=2*(p2.x-p1.x);
    *b=2*(p2.y-p1.y);
    *c=p1.x*p1.x+p1.y*p1.y-(p2.x*p2.x+p2.y*p2.y);
}

int main(void){
    int i,n;
    double a1,b1,c1,a2,b2,c2,r;
    point p1,p2,p3;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
        renritu(p1,p2,&a1,&b1,&c1);
        renritu(p2,p3,&a2,&b2,&c2);
        p3.x=-(b2-a2)*c1/(a1*b2-a2*b1);
        p3.y=-(a1-b1)*c2/(a1*b2-a2*b1);
        r=sqrt((p3.x-p1.x)*(p3.x-p1.x)+(p3.y-p1.y)*(p3.y-p1.y));
        printf("%.3lf %.3lf %.3lf\n",round(p3.x*1000)/1000,round(p3.y*1000)/1000, round(r*1000)/1000);
    }
    return 0;
}