llround()函数以及C ++中的示例
C++llround()函数
llround()函数是cmath标头的库函数,用于舍入给定值并将其转换为长整型整数,它接受一个数字并返回最接近该数字的整数(长整型int)值(带有中途案例)。
llround()函数语法:
llround(x);
参数:x–是中途取整的数字,最接近零。
返回值:longlongint–返回longlongint类型值,该值是数字x的舍入值。
示例
Input:
float x = 2.3;
Function call:
llround(x);
Output:
2
Input:
float x = 2.8;
Function call:
llround(x);
Output:
3C++代码演示llround()函数示例
//示例
//llround()功能
#include <iostream>
#include <cmath>
using namespace std;
//main()部分
int main(){
float x;
x = 15.3;
cout<<"llround("<<x<<"): "<<llround(x)<<endl;
x = 15.5;
cout<<"llround("<<x<<"): "<<llround(x)<<endl;
x = 15.8;
cout<<"llround("<<x<<"): "<<llround(x)<<endl;
x = -15.3;
cout<<"llround("<<x<<"): "<<llround(x)<<endl;
x = -15.5;
cout<<"llround("<<x<<"): "<<llround(x)<<endl;
x = -15.8;
cout<<"llround("<<x<<"): "<<llround(x)<<endl;
return 0;
}输出结果
llround(15.3): 15 llround(15.5): 16 llround(15.8): 16 llround(-15.3): -15 llround(-15.5): -16 llround(-15.8): -16
热门推荐
10 朋友新年祝福语大全 简短
11 新年祝福语简短大方兔年
12 搬新家礼物祝福语简短
13 同学见面花束祝福语简短
14 五一假期祝福语幽默简短
15 离职欢送敬酒祝福语简短
16 对学弟的祝福语简短
17 考老师辞职祝福语简短
18 祝福语驱散霉运的话简短