7 solutions

  • 0
    @ 2026-10-28 16:47:51
    #include <bits/stdc++.h>
    #include <cmath>
    using namespace std;
    
    int main()
    {
        double x;
        cin>>x;
        //方法一:纯数学四舍五入思想
         if((x-0.5)>=int(x)){
            cout<<int(x)+1<<endl;
        }
        else{
            cout<<int(x)<<endl;
        }
        //方法二:cmath函数
        // cout<<round(x)<<endl;
        return 0;
    }
    

    Information

    ID
    2295
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    1
    Tags
    (None)
    # Submissions
    176
    Accepted
    100
    Uploaded By