#includeC语言函数#include #include using namespace std; int main(){ double a; cin >> a; cout << floor(a) << endl << ceil(a) << endl; return 0; }
#include
double floor(double x); // 函数接口
double ceil(double x); //函数接口
使用floor函数。floor(x)返回的是小于或等于x的最大整数。
如: floor(10.5) == 10 floor(-10.5) == -11
使用ceil函数。ceil(x)返回的是大于x的最小整数。
如: ceil(10.5) == 11 ceil(-10.5) ==-10
floor()是向负无穷大舍入,floor(-10.5) == -11;
ceil()是向正无穷大舍入,ceil(-10.5) == -10
牛客网NC22001



