floor函数
地板函数,返回的是小于等于这个值的数;
floor(1.2)=1.0;
floor(2.0)=2.0;
ceil函数
天花板函数,返回值是大于等于这个数的值。
ceil(1.2)=2.0;
ceil(2.0)=2.0;
round函数
四舍五入。
round(2.5)=3.0;
round(2.1)=2.0;
代码:
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
int main()
{
double n,m;
scanf("%lf%lf",&n,&m);
printf("%lf %lf\n",floor(n),floor(m));
printf("%lf %lf\n",ceil(n),ceil(m));
printf("%lf %lf\n",round(n),round(m));
return 0;
}