【題解】TIOJ 1506 . 二元一次聯立方程式

【題目敘述】https://tioj.ck.tp.edu.tw/problems/1506

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

double a1, a2, b1, b2;
double x, y;

int main() {
    cin >> a1 >> a2 >> b1 >> b2;
    x = (b2-b1) / (a1-a2);
    y = a1 * x  + b1;
    x *= 100;
    x = round(x);
    if (x == -0.0) x = 0.0;
    y *= 100;
    y = round(y);
    if (y == -0.0) y = 0.0;
    cout << fixed << setprecision(2) << x/100 << "\n" << y/100 << "\n";
}
分享本文 Share with friends