#include <iostream>
using namespace std;
int main()
{
int a, b, c, d, e, f, X, Y, m;
float nx, ny, s;
cin >> m;
int ans[2][m] = {{0},{0}};
for (int i = 0; i < m; i++){
cin >> a >> b >> c >> d >> e >> f;
if (a != 0 && b != 0 && d!= 0 && e!= 0){
nx = a / d;
ny = b - e * nx;
s = c - f * nx;
Y = s / ny;
X = (c - Y * b) / a;
}
else if(a == 0){
Y = c / b;
X = (f - e * Y) / d;
}
else if(b == 0){
X = c / a;
Y = (f - d * X) / e;
}
else if(d == 0){
Y = f / e;
X = (c - b * Y) / a;
}
else if(e == 0){
X = f / d;
Y = (c - a * X) / b;
}
ans[0][i] = X;
ans[1][i] = Y;
}
for(int i = 0; i < m; i++){
cout << ans[0][i] << " " << ans[1][i] << "\n";
}
return 0;
}
1.
nx = a / d;
1. 這裡是整數除法,結果會與你想的差很多
2. 你的方法會有浮點的誤差