1 条题解

  • 0
    @ 2024-3-25 20:19:19
    //方法1:
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a, b;
        scanf("%d%d", &a, &b);
        printf("%.3f%%", 100.0 * b / a); // %.3f 占位符保留三位小数输出
        //输出 %要 printf("%%")。 
        return 0;
    }
    /*方法2: 
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a, b;
        cin >> a >> b;
        cout << fixed << setprecision(3) << 100.0 * b / a << '%' << endl;
        // 保留三位小数输出
        return 0;
    }
    */ 
    
    • 1

    信息

    ID
    12
    时间
    1000ms
    内存
    128MiB
    难度
    3
    标签
    递交数
    54
    已通过
    28
    上传者