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++: #include<bits/stdc++.h>
using namespace std;
typedef complex<double> point;
typedef pair<point, point> line;
double cross(point a, point b){
  return imag(conj(a) * b);
}


point cross_point(line a, line b){
  double d1 = cross(b.second - b.first,
                    b.first - a.first);
  double d2 = cross(b.second - b.first,
                    a.second - a.first);
  return a.first + (a.second - a.first) * (d1/d2);
}

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    point x[3];
    for (int j = 0; j < 3; j++) {
      double real, imag;
      cin >> real >> imag;
      x[j] = point(real, imag);
    }
    point m1 = (x[0] - x[1]), m2 = (x[1] - x[2]);
    m1 = point(m1.real()/2, m1.imag()/2);
    m2 = point(m2.real()/2, m2.imag()/2);
    line n1 = line(m1*point(0, 1), m1*point(0, -1)),
      n2 = line(m2*point(0, 1), m2*point(0, -1));
    n1.first += m1 + x[0];
    n1.second += -m1 + x[0];
    n2.first += m2 + x[1];
    n2.second += -m2 + x[1];
      
    point center = cross_point(n1, n2);
    std::cout << center.real() << " " << center.imag() << " " <<
      abs(center - x[0]) << std::endl;
  }
  return 0;
}

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

int main(){
    double x1,y1,x2,y2,x3,y3;
    int n;
    cin >> n;
    double a,b,c;
    double ans1,ans2;
    for(int i=0;i<n;i++){
        double ans = 0;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        a = hypot(x2 - x1,y2 - y1);
        b = hypot(x3 - x1,y3 - y1);
        c = hypot(x3 - x2,y3 - y2);
        ans = (a*b*c) / (sqrt((a+b+c)*(b+c-a)*(a-b+c)*(a+b-c)));
        ans1 = (((x1*x1)+(y1*y1))*(y2-y3)+((x2*x2)+(y2*y2))*(y3-y1)+((x3*x3)+(y3*y3))*(y1-y2))/(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2;
        ans2 = (((x1*x1)+(y1*y1))*(x2-x3)+((x2*x2)+(y2*y2))*(x3-x1)+((x3*x3)+(y3*y3))*(x1-x2))/(y1*(x2-x3)+y2*(x3-x1)+y3*(x1-x2))/2;
        printf("%.3lf %.3lf %.3lf\n",ans1,ans2,ans);
    }
}

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

using namespace std;
typedef struct { double x; double y;} point;
 
point getCircumcenter(point a, point b, point c)
{
    double A1 = 2 * ( b.x - a.x );
    double B1 = 2 * ( b.y - a.y );
    double C1 = pow(a.x,2)-pow(b.x,2) + pow(a.y,2)-pow(b.y,2);
    double A2 = 2 * ( c.x - a.x );
    double B2 = 2 * ( c.y - a.y );
    double C2 = pow(a.x,2)-pow(c.x,2) + pow(a.y,2)-pow(c.y,2);
    double X = (B1 * C2 - B2 * C1) / (A1 * B2 - A2 * B1);
    double Y = (C1 * A2 - C2 * A1) / (A1 * B2 - A2 * B1);
	point P;
	P.x=X;
	P.y=Y;
    return P;
}

double getTwoPointDictance(point a, point b)
{
	return fabs(sqrt(pow((a.x-b.x),2)+pow((a.y-b.y),2)));
}
double AntiMinusZero(double n)
{
	if(n=0)
	{
		return 0;
	}
	return n;
}

int main()
{
    int n;
    cin>>n;
    point a,b,c;
    while(n--)
	{
        cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y;
        point ans = getCircumcenter(a,b,c);
        printf("%.3lf %.3lf %.3lf", AntiMinusZero(ans.x), AntiMinusZero(ans.y), AntiMinusZero(getTwoPointDictance( a, ans)));
    }
}

C++: #include <iostream>
#include "stdio.h"

#define MAX 1000000

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 <cmath>
#include <algorithm>
using namespace std;

const double EPS = 1e-5;

double dist(double x1, double y1, double x2, double y2) {
  return sqrt(pow(x2-x1, 2) + pow(y2-y1, 2));
}

int main() {
  int n;
  double x[3], y[3], a, b, c, sa, ca;
  double px, py, r;
  cin >> n;
  for (int k=0;k<n;k++) {
    for (int i=0;i<3;i++) {
      cin >> x[i] >> y[i];
    }
    a = dist(x[1], y[1], x[2], y[2]);
    b = dist(x[0], y[0], x[1], y[1]);
    c = dist(x[0], y[0], x[2], y[2]);
    ca = (a*a - b*b - c*c) / (2*b*c);
    sa = sqrt(1 - ca*ca);
    r = a / sa / 2;

    for (px=-r;px<=r;px+=0.000001) {
      py = sqrt(r*r - px*px);
      if (abs(pow(px-x[0], 2) + pow(py-y[0], 2) - r*r) < EPS &&
          abs(pow(px-x[1], 2) + pow(py-y[1], 2) - r*r) < EPS &&
          abs(pow(px-x[2], 2) + pow(py-y[2], 2) - r*r) < EPS) {
        break;
      }
    }
    printf("%.3f %.3f %.3f\n", px, py, r);
  }
  return 0;
}

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

void gradcut(double *a,double *b,double x1,double y1,double x2,double y2);
double fixzero(double z){
    if (fabs(z) < 1e-6) return fabs(z);
    else return z;
}
int main() {
    double x[3],y[3],a[2],b[2],rx,ry,r;
    int n;
    std::cin >> n;
    for(int j=0;j<n;j++){
        int am=0,add=1;;
        for(int i=0;i<3;i++) std::cin >> x[i] >> y[i];
        for(int i=0;i<3;i++){
            if(i==2) add=-2;
            if(x[i]!=x[i+add]&&y[i]!=y[i+add]){
                gradcut(&a[am],&b[am],x[i],x[i+add],y[i],y[i+add]);
                am++;
                if(am>2) break;
            }else if(x[i]==x[i+add]){
                a[am]=0;
                b[am]=(y[i]+y[i+add])/2;
                am++;
                if(am>2) break;
            }
        }


        rx = (b[1]-b[0])/(a[0]-a[1]);
        ry = a[0]*rx+b[0];
        r=sqrt((x[0]-rx)*(x[0]-rx)+(y[0]-ry)*(y[0]-ry));
        printf("%.3f %.3f %.3f\n",fixzero(rx),fixzero(ry),fixzero(r));
    }
    return 0;
}

void gradcut(double *a,double *b,double x1,double x2,double y1,double y2){
    *a=-(x2-x1)/(y2-y1);
    *b=(y1+y2)/2-(*a)*(x1+x2)/2;
}

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

using namespace std;

typedef complex<double> Point;

bool eqv(double d1, double d2) {
    return abs(d1-d2) < 1e-4;
}

int main() {
    int N;
    double x1, x2, x3, y1, y2, y3;

    while(true) {
        cin >> N;
        if(!N) break;

        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Point p1(x1, y1), p2(x2, y2), p3(x3, y3);

        double R = abs(abs(p3-p2) / sin(arg(p2-p1) - arg(p3-p1))) / 2;
        Point pc = (p1+p2) / 2.;
        Point ph1 = (pc-p1) * Point(0, 1);
        double L = sqrt(R*R - norm(pc-p1));
        Point center = pc + ph1 * L / abs(ph1);
        if(!eqv(abs(center-p1), abs(center-p2)) ||
           !eqv(abs(center-p1), abs(center-p3)) ||
           !eqv(abs(center-p3), abs(center-p2))) center = pc - ph1*L/abs(ph1);


        printf("%.3f %.3f %.3f\n", center.real(), center.imag(), R);
    }
    return 0;
}