tc 怎么进行四舍五入

来源:百度知道 编辑:UC知道 时间:2024/05/20 22:12:05
老师出了个题 你输入打电话的时间,求电话费
电话费是 0.21RMB/3分钟 (不足3分钟按3分钟算) 用 if 或 switch 语句做 。
请写简单点。。 本人还是菜鸟 。。 看不懂太深的东东。

给你一个C库函数ceil (if x is a real number, x<n and x>n-1, then ceil(x) = n)
Calculates the ceiling of a value.

double ceil(
double x
);
float ceil(
float x
); // C++ only
long double ceil(
long double x
); // C++ only
float ceilf(
float x
);

Parameters
x
Floating-point value.

Return Value
The ceil function returns a double value representing the smallest integer that is greater than or equal to x. There is no error return.

<math.h>

我这只是给你个关键的函数而已。其他的很简单了