数学函数库

一、math.h

1.

p

o

w

pow

pow函数:指数函数

头文件:math.h原型:double pow(double a, double b);返回值:

a

b

{a}^{b}

ab的结果a:底数b:指数例:pow(2,3) = 8

2.

s

q

r

t

sqrt

sqrt函数:平方根函数

头文件:math.h原型:double sqrt(double x);返回值:

x

\sqrt{x}

x

​的结果x:被开方数例:sqrt(16) = 4

3.

c

e

i

l

ceil

ceil函数:上取整函数(天花板函数)

头文件:math.h原型:double ceil(double x);返回值:返回

\lceil

⌈x

\rceil

⌉的结果x:某个实数例:ceil(4.1) = 5

4.

f

l

o

o

r

floor

floor函数:下取整函数

头文件:math.h原型:double floor(double x);返回值:返回

\lfloor

⌊x

\rfloor

⌋的结果x:某个实数例:floor(4.1) = 4

5.

f

a

b

s

fabs

fabs函数:实数绝对值函数

头文件:math.h原型:double fabs(double x);`返回值:返回

|

∣x

|

∣的结果x:某个实数例:abs(-4.5) = 4.5

6.

l

o

g

log

log函数:以

e

e

e为底对数函数

头文件:math.h原型:double log(double x);返回值:返回

log

a

{\log}_{a}

loga​

x

x

x的结果x:某个实数例:log(9) = 2.197225

7.

l

o

g

10

log10

log10函数:以10为底对数函数

头文件:math.h原型:double log10(double x);返回值:返回

log

10

{\log}_{10}

log10​

x

x

x的结果x:某个实数例:log10(1000) = 3

8.

a

c

o

s

acos

acos函数:三角函数

头文件:math.h原型:double acos(double x);返回值:返回

a

c

o

s

acos

acos

(

x

)

(x)

(x)的结果x:角度的弧度值例:acos(-1) = 3.1415936...

二、stdlib.h

1.abs函数:绝对值函数

头文件:stdlib.h原型:int abs(int x);返回值:返回

|

∣x

|

∣的结果x:某个实数例:abs(-4) = 4

练习

输入x,输出x的立方根。

具体代码

#include

#include

int main(){

double x,a;

scanf("%lf",&x);

a=pow(x,1.0/3.0);

printf("立方根=%lf",a);

return 0;

}

}

角度转弧度

具体代码

#include

#include

#define PI acos(-1)

int main(){

double x,a;

scanf("%lf",&x);

a=PI / 180.0 * x;

printf("立方根=%lf",a);

return 0;

}

好文阅读

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: