uTools-Manuals/docs/c/abs.html
2019-04-08 23:22:26 +08:00

38 lines
694 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1>数学函数 - abs</h1>
<p>原型extern int abs(int x);</p>
<p>用法:#include &lt;math.h></p>
<p>功能求整数x的绝对值</p>
<p>说明:计算|x|, 当x不为负时返回x否则返回-x</p>
举例:<pre>
// abs.c
#include &lt;syslib.h>
#include &lt;math.h>
main()
{
int x;
clrscr(); // clear screen
x=-5;
printf("|%d|=%d\n",x,abs(x));
x=0;
printf("|%d|=%d\n",x,abs(x));
x=+5;
printf("|%d|=%d\n",x,abs(x));
getchar();
return 0;
}
</pre>相关函数:<a href="fabs.html">fabs</a>