Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func gcd(num1, num2 int) int {
	if num2 == 0 {
		return num1
	}
	num3 := num1 % num2
	return gcd(num2, num3)
}

func lcm(num1, num2 int) int {
	if num1%num2 != 0 {
		num3 := gcd(num1, num2)
		for i := 1; ; i++ {
			check := num3 * i
			if check%num1 == 0 && check%num2 == 0 {
				return check
			}
		}
	} else {
		return num1
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		strNums := strings.Fields(scanner.Text())
		nums := []int{}
		for _, strNum := range strNums {
			num, _ := strconv.Atoi(strNum)
			nums = append(nums, num)
		}
		a := nums[0]
		b := nums[1]
		c := nums[2]
		d := nums[3]
		e := nums[4]
		f := nums[5]
		lcm := lcm(a, d)
		mulA := lcm / a
		mulD := lcm / d
		a *= mulA
		b *= mulA
		c *= mulA
		d *= mulD
		e *= mulD
		f *= mulD

		if d < 0 {
			d *= -1
			e *= -1
			f *= -1
		}

		bE := b - e
		cF := c - f
		y := float64(cF) / float64(bE)
		x := (float64(c) - (y * float64(b))) / float64(a)

		if x == 0 {
			fmt.Printf("%.3f ", 0.0)
		} else {
			fmt.Printf("%.3f ", x)
		}
		if y == 0 {
			fmt.Printf("%.3f\n", 0.0)
		} else {
			fmt.Printf("%.3f\n", y)
		}
	}
}

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

class Calc{
    public:
    double A[N][N+1];
    int i, j, k;

    void calcSi();
    void printSi();
}

void Calc::calcSi(){
    for(i=0;i<N-1;i++){
        for(j=i+1;j<N;j++){
            int tmp = A[j][i] / A[i][i];
            for(k=i+1; k<=N; k++)
                A[j][k] -= A[i][k] * tmp;
        }
    }

    for(i=N-1; i>=0; i--){
        tmp = A[i][N];
        for(j=i+1;j<N;j++)
            tmp -= A[i][j] * A[j][N];
        A[i][N] = tmp / A[i][i];
    }
}

void Calc::printSi(){
    for(i=0;i<N;i++){
        printf("%.3f",A[i][N]);
        if(i != N) {
            cout << " ";
        }
    }
    cout << endl;
}

int main(void){
    Calc c;
    int i;
    while(cout >> c.A[0][0] >> c.A[0][1] >> c.A[0][2] >> c.A[1][0] >> c.A[1][1] >> c.A[1][2])
    {
        c.calcSi();
        c.printSi();
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector> 
#include <iomanip>
int main()
{
	std::vector<double> x, y;
	double a, b, c, d, p, q;
	while (scanf("%d %d %d %d %d %d", &a, &b, &p, &c, &d, &q) != EOF)
	{
		x.push_back((d*p - b*q) / (a*d - b*c));
		y.push_back((a*q - c*p) / (a*d - b*c));
	}

	for (int i = 0; i < x.size(); ++i)
		std::cout << std::setprecision(10) << x[i] << " " << std::setprecision(10) << y[i] << std::endl;
	return 0;
}

C++: #include <iomanip>
#include <iostream>
#include <vector>
#define N 2
 
using namespace std;
typedef vector< vector<double> > Equation;
 
bool input(Equation& c)
{
	if (!cin) return false;

    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N + 1; ++j)
            cin >> c[i][j];
 
    return true;
}
 
int main()
{
    Equation c(N, vector<double>(N + 1));
	while (cin)
	{
		for (int i = 0; i < N; ++i)
			for (int j = 0; j < N + 1; ++j)
				cin >> c[i][j];

		// Gaussian elimination
		// 1. Forward elimination
        for (int i = 0; i < N - 1; ++i)
            for (int j = i + 1; j < N; ++j)
            {
                double d = c[j][i] / c[i][i];
                for (int k = i + 1; k <= N; ++k)
                    c[j][k] -= c[i][k] * d;
            }
 
		// 2. Back substitution
        for (int i = N - 1; i >= 0; --i)
        {
            double d = c[i][N];
            for (int j = i + 1; j < N; ++j)
                d -= c[i][j] * c[j][N];
            c[i][N] = d / c[i][i];
        }
 
        cout << setprecision(4) << fixed << c[0][N];
        for (int i = 1; i < N; ++i)
            cout << " " << c[i][N];
        cout << endl;
    }
 
    return 0;
}

C++:  #include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(){
    double a , b , c , d , e , f;
    while(cin >> a >> b >> c >> d >> e >> f){
    double t = a;
    a = a*d;
    b = b*d;
    c = c*d;
    d = d*t;
    e = e*t;
    f = f*t;
    double g = b-e;
    double h = c-f;
    double y = h/g;
    double x = (c- b*y) / a ;
    x = x * 1000;
    x = round(x);
    x = x/1000;
    y = y*1000;
    y = round(y);
    y = y/1000;
    printf("%.3lf %.3lf\n" , x  , y );
}
}

C++: #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
using namespace std;
#define j bai;
int main() {
	double a, b, c, d, e, y, x, f, bai;
	bool bo = false;
	while (cin >> a >> b >> c >> d >> e >> f) {
		if (a) {
			y = c / b;
			x = f / d - e*y;
		}
		if (b) {
			x = a / c;
			y = f / e - d*x;
		}

		if (d) {
			y = f / e;
			x = c / a - d*y;
		}
		if (e) {
			x = f / d;
			y = f / e - d*x;
		}
		else if (a < d) {
			bai = d / a;
			a *= j;
			b *= j;
			c *= j;
		}
		else {
			bai = a / d;
			d *= j;
			e *= j;
			f *= j;
		}
		if (((a > 0 && d < 0) || (a < 0 && d>0)) && bo == false) {
			y = (c + f) / (b + e);
			x = (c - b*y) / a;
		}
		else if (bo == false) {
			y = (c - f) / (b - e);
			x = (c - b*y) / a;
		}
		if (x == -0.000) {
			x = abs(x);
		}
		if (y == -0.000) {
			y = abs(y);
		}
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

C++: #include <stdio.h>
#include <math.h>

int main(){
  int i = 0;
  while(1){
  i++;
  int a, b, c, d, e, f;
  scanf("%d ",&a);
  scanf("%d ",&b);
  scanf("%d ",&c);
  scanf("%d ",&d);
  scanf("%d ",&e);
  scanf("%d ",&f);
  
  double x, y;
  x = (double)(c*e-b*f) / (double)(a*e-b*d);
  y = (double)(a*f-c*d) / (double)(a*e-b*d);
  x = (double)round(x*10000.0) / 10000.0;
  y = (double)round(y*10000.0) / 10000.0;
  printf("%.3f %.3f\n", x, y);
  
  int line = ftell(stdin);
  if(scanf("%d", &a)==EOF) break;
  else{
    fseek(stdin, line, SEEK_SET);
  }
  }
  
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
int a,b,c,d,e,f;
double A[2][2];
double B[2];
double inv_A[2][2];
scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
int det = a*e-b*d;
A[0][0]=a; A[0][1] = b;
A[1][0]=d; A[1][1] = e;
B[0] = c;
B[1] = f; 

inv_A[0][0]=1.0/(double)det *A[1][1]; inv_A[0][1]=1.0/(double)det *-A[0][1];
inv_A[1][0]=1.0/(double)det *-A[1][0]; inv_A[1][1]=1.0/(double)det *A[0][0];

double res[2];
res[0]=0;
res[1]=0;

for(int i=0;i<2;i++){
for(int j=0;j<2;j++){
for(int k=0;k<2;k++){
res[i]+=inv_A[j][k]*B[k];
}
}
}

printf("%.3f %.3f\n",res[0],res[1]);
}

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

using namespace std;

int main(){
double a=1, b, c, d, e, f;

while(a){
cin >> a >> b>> c>> d>> e>> f;
double x, y;
x =(c*e-b*f) / (a*e-b*d);
y = (c*d-a*f) / (b*d-a*e);
printf("%.3f %.3f\n",x, y);
}

return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
int a,b,c,d,e,f;
double A[2][2];
double B[2];
double inv_A[2][2];
while(~scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)){
int det = a*e-b*d;
A[0][0]=a; A[0][1] = b;
A[1][0]=d; A[1][1] = e;
B[0] = c;
B[1] = f; 

inv_A[0][0]=A[1][1]; inv_A[0][1]=-A[0][1];
inv_A[1][0]=-A[1][0]; inv_A[1][1]=A[0][0];

double res[2];
res[0]=0;
res[1]=0;


for(int j=0;j<2;j++){
for(int k=0;k<2;k++){
res[j]+=1.0/(double)det *inv_A[j][k]*B[k];
}
}

printf("%.3f %.3f\n",res[0],res[1]);
}
}

C++: #include<iostream>
using namespace std;
int main(){
  double a, b, c, d, e, f;
  double x, y;
  cin >> a >> b >> c >> d >> e >> f;
  x = (c * e - b * f) / (a * e - b * d);
  y = (a * f - c * d) / (a * e - b * d);
  cout << x << " " << y << endl;
  return 0;
}