1 条题解

  • 1
    @ 2024-4-5 16:27:35
    #include <iostream>
    #include <iomanip>
    #include <cmath>
    
    using namespace std;
    
    string divide(int a, int b, int n) {
        string result = to_string(a / b) + "."; // 整数部分
    
        // 计算小数部分
        int remainder = a % b;
        for (int i = 0; i < n; ++i) {
            remainder *= 10;
            result += to_string(remainder / b);
            remainder %= b;
        }
    
        return result;
    }
    
    int main() {
        int a, b, n;
        cin >> a >> b >> n;
    
        cout << divide(a, b, n) << endl;
    
        return 0;
    }//ac了,放心用,真的很简单,希儿会保护大家的
    
    • 1

    信息

    ID
    269
    时间
    1000ms
    内存
    16MiB
    难度
    3
    标签
    递交数
    38
    已通过
    21
    上传者