求助

B2016 浮点数向零舍入

Curry_Skyfxxker @ 2022-07-25 20:37:12

#include<bits/stdc++.h>
using namespace std;
int main(){
    float a;
    cin>>a;
    if(a>0){
        cout<<floor(a);
    }
    else{
        cout<<ceil(a);
    }
    return 0;
} 

by Jackson_Miller @ 2022-07-25 20:43:25

#include <bits/stdc++.h>
using namespace std;
int main(){
    double a;
    cin>>a;
    cout<<(long long)a;
return 0;
}

@Curry_Skyfxxker


by _cyh0412_ @ 2022-07-25 20:45:30

其实不需要那么麻烦,无需if语句,只需:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a;//float a也可以
    cin>>a;//输入
    cout<<(long long)a<<endl;//输出
    return 0;//结束
}

|