60分半江瑟瑟半江红求救!!!

B2016 浮点数向零舍入

__Harry_Haiyun__ @ 2023-05-10 18:28:36


#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    double num;
    cin >> num;
    if (num >= 0) cout << floor(num);
    else cout << ceil(num);
    return 0;
} 

by LiJoQiao @ 2023-05-10 18:37:20

直接定义一个longlong类型的变量赋值就行了。


by huangyifan1688 @ 2023-05-19 20:57:09

@Harry_Haiyun

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

by HackerLzh @ 2023-05-20 15:31:12

注意floor和ceil的返回值并不是整形,要强转,这题则是要强转成longlong


|