L1-037 A除以B 分數 10

Frodnx發表於2024-08-03

有點坑的10分題,讀題不仔細會WA幾次

// 4'58"
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    cout << a << "/";
    if(b < 0) cout << "(";
    cout << b;
    if(b < 0) cout << ")";
    cout << "=";
    if(b == 0) cout << "Error";
    else  cout << fixed << setprecision(2) << (double)a / (double)b;
    return 0;
}

相關文章