ceil()

ceil()函数是这样的:

double ceil(double x)

ceil函数可以把x上取整。

例子:

#include <bits/stdc++.h>
using namespace std;
int main() {
	double a, b;
	cin >> a >> b;
	printf("ceil(%.2f) = %.2f\n", a, ceil(a));
	printf("ceil(%.2f) = %.2f\n", b, ceil(b));
}

运行结果:

 floor()

floor()函数是这样的:

double floor(double x)

floor函数可以把x上取整。

例子:

#include <bits/stdc++.h>
using namespace std;
int main() {
	double a, b;
	cin >> a >> b;
	printf("floor(%.2f) = %.2f\n", a, floor(a));
	printf("floor(%.2f) = %.2f\n", b, floor(b));
}

运行结果: 

 round()

round()函数是这样的:

double round(double x)

round函数可以把x上取整。

例子:

#include <bits/stdc++.h>
using namespace std;
int main() {
	double a, b;
	cin >> a >> b;
	printf("round(%.2f) = %.2f\n", a, round(a));
	printf("round(%.2f) = %.2f\n", b, round(b));
}

运行结果: