C 库函数 - labs()

C 语言教程 · 2019-02-24 10:26:56

描述

C 库函数 long int labs(long int x) 返回 x 的绝对值。

声明

下面是 labs() 函数的声明。

long int labs(long int x)

参数

  • x -- 完整的值。

返回值

该函数返回 x 的绝对值。

实例

下面的实例演示了 labs() 函数的用法。

#include <stdio.h>
#include <stdlib.h>

int main ()
{
   long int a,b;

   a = labs(65987L);
   printf("a 的值 = %ld\n", a);

   b = labs(-1005090L);
   printf("b 的值 = %ld\n", b);
   
   return(0);
}

让我们编译并运行上面的程序,这将产生以下结果:

a 的值 = 65987
b 的值 = 1005090

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

Learning Vue.js 2

Learning Vue.js 2

Olga Filipova / Packt Publishing / 2017-1-5 / USD 41.99

About This Book Learn how to propagate DOM changes across the website without writing extensive jQuery callbacks code.Learn how to achieve reactivity and easily compose views with Vue.js and unders......一起来看看 《Learning Vue.js 2》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具