C 库函数 - abs()

C 语言教程 · 2019-02-24 09:56:25

描述

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

声明

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

int abs(int x)

参数

  • x -- 完整的值。

返回值

该函数返回 x 的绝对值。

实例

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

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

int main ()
{
   int a, b;

   a = abs(5);
   printf("a 的值 = %d\n", a);

   b = abs(-10);
   printf("b 的值 = %d\n", b);
   
   return(0);
}

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

a 的值 = 5
b 的值 = 10

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

查看所有标签

The Probabilistic Method

The Probabilistic Method

Noga Alon、Joel H. Spencer / Wiley-Interscience / 2008-8-11 / USD 137.00

Praise for the Second Edition : "Serious researchers in combinatorics or algorithm design will wish to read the book in its entirety...the book may also be enjoyed on a lighter level since the diffe......一起来看看 《The Probabilistic Method》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器