80?

B2016 浮点数向零舍入

Kuangxirui @ 2023-12-07 13:02:32

#include<bits/stdc++.h>
using namespace std;
int main(){
    double a;
    cin>>a;
    if(a>0) 
    printf("%.0f",a);
    else if(a<0){
     printf("%.0f",a);
     }
     else if(a==0)cout<<"0";    
     return 0;
}

by dienter @ 2023-12-07 13:06:46

@Kuangxirui

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

不开ll见祖宗


by 孙轩宇 @ 2023-12-07 17:42:17

@Kuangxirui 把最后一个else if(a==0)改成else试试


by Kuangxirui @ 2023-12-10 11:52:52

@孙轩宇 thank you


by Kuangxirui @ 2023-12-10 11:53:17

@dienter thank you


|