博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c++ cstdlib_C ++中带有示例的abs()函数(cstdlib / stdlib.h)
阅读量:2532 次
发布时间:2019-05-11

本文共 1523 字,大约阅读时间需要 5 分钟。

c++ cstdlib

C ++ abs()函数 (C++ abs() function)

abs() function is a library function of cstdlib header. It is used to get the absolute value. It accepts a value (int, long int, long long it) and returns its absolute value. This method is an overloaded method of (that is used for getting absolute value of the floating-point values).

abs()函数cstdlib标头的库函数。 用于获取绝对值。 它接受一个值(int,long int,long long it)并返回其绝对值。 此方法是的的重载方法用于获取浮点值的绝对值)。

Syntax of abs() function:

abs()函数的语法:

C++11:

C ++ 11:

int abs (int n);    long int abs (long int n);    long long int abs (long long int n);

Parameter(s):

参数:

  • n – represents an Integral value whose absolute value to found.

    n –表示要找到其绝对值的整数值。

Return value:

返回值:

It returns the absolute value of n.

它返回n的绝对值。

Example:

例:

Input:    n = -10        Function call:    abs(n);        Output:    10    Input:    n = 10        Function call:    abs(n);        Output:    10

C ++代码演示abs()函数的示例 (C++ code to demonstrate the example of abs() function)

// C++ code to demonstrate the example of// abs() function#include 
#include
using namespace std;// main() sectionint main(){ int n; n = -10; cout << "abs(" << n << "): " << abs(n) << endl; n = 10; cout << "abs(" << n << "): " << abs(n) << endl; n = -12345678; cout << "abs(" << n << "): " << abs(n) << endl; n = 12345678; cout << "abs(" << n << "): " << abs(n) << endl; return 0;}

Output

输出量

abs(-10): 10abs(10): 10 abs(-12345678): 12345678abs(12345678): 12345678

Reference:

参考:

翻译自:

c++ cstdlib

转载地址:http://ewozd.baihongyu.com/

你可能感兴趣的文章
JQuery制作简单的网页导航特效
查看>>
操作系统简述
查看>>
设计模式大总结2-结构型模式
查看>>
【Python】不定期更新学习小问题整理
查看>>
Zico源代码分析:执行启动过程分析和总结
查看>>
Android之Http通信——1.初识Http协议
查看>>
hdu5044(二分)
查看>>
静态路由、缺省路由的作用
查看>>
linux快捷键绝对路径相对路径讲解
查看>>
又漏一次
查看>>
dede模板中plus文件路径使用方法
查看>>
xml解析demo使用
查看>>
python使用模板手记
查看>>
No result defined for action com.nynt.action.ManageAction and result input问题
查看>>
iOS开发拓展篇—UIDynamic(重力行为+碰撞检测)
查看>>
洛谷 P3627 [APIO2009](抢掠计划 缩点+spfa)
查看>>
c++ 连接数据库
查看>>
函数指针与回调函数
查看>>
你所不知道的 CSS 滤镜技巧与细节
查看>>
hack reviewboard 让 FireFox 把 tab 显示为 4 或 2 个空格
查看>>