c语言函数库第五章(数学函数)1.abs、labs、fabs:求绝对值函数..........................................................................12.acos:反余弦函数...............................................................................................23.asin:反正弦函数................................................................................................34.atan:反正切函数..................................................................................................35.atan2:反正切函数2.............................................................................................46.ceil:向上舍入函数...............................................................................................47.cos:余弦函数.....................................................................................................58.cosh:双曲余弦函数...........................................................................................59.div、ldiv:除法函数.............................................................................................610.exp:求e的x次幂函数...................................................................................711.floor:向下舍入函数.........................................................................................812.fmod:求模函数.................................................................................................813.frexp:分解浮点数函数.....................................................................................914.hypot:求直角三角形斜边长函数....................................................................915.ldexp:装载浮点数函数..................................................................................1016.log、log10:对数函数.....................................................................................1017.modf:分解双精度数函数...............................................................................1118.pow、pow10:指数函数.................................................................................1219.rand:产生随机整数函数................................................................................1220.sin:正弦函数..................................................................................................1321.sinh:双曲正弦函数......................................................................................1322.sqrt:开平方函数.............................................................................................1423.srand:设置随机时间的种子函数..................................................................1424.tan:正切函数................................................................................................1525.tanh:双曲正切函数........................................................................................161.abs、labs、fabs:求绝对值函数函数原型:intabs(intx);longlabs(longx);doublefabs(doublex);头文件:#includemath.h是否是标准函数:是函数功能:函数intabs(intx);是求整数x的绝对值;函数longlabs(longn);是求长整型数x的绝对值;函数doublefabs(doublex);是求浮点数x的绝对值。返回值:返回计算结果。例程如下:计算整数的绝对值。#includemath.hintmain(void){intx=-56;printf(number:%dabsolutevalue:%d\n,x,abs(x));return0;}例程说明:本例程通过abs函数计算出整型数-56的绝对值56,并在屏幕上显示结果。本例程的运行结果为:number:-56absolutevalue:56例程如下:计算长整数的绝对值。#includemath.hintmain(void){longx=-12345678L;printf(number:%ldabsolutevalue:%ld\n,x,labs(x));return0;}例程说明:本例程通过labs函数计算出长整型数-12345678的绝对值12345678,并在屏幕上显示结果。本例程的运行结果为:number:-12345678absolutevalue:12345678例程如下:计算浮点数的绝对值。#includemath.hintmain(void){floatx=-128.0;printf(number:%fabsolutevalue:%f\n,x,fabs(x));return0;}例程说明:本例程通过fabs函数计算出浮点数-128.0的绝对值128.0,并在屏幕上显示结果。本例程的运行结果为:number:-128.000000absolutevalue:128.0000002.acos:反余弦函数函数原型:doubleacos(doublex);头文件:#includemath.h是否是标准函数:是函数功能:求x的反余弦值,这里,x为弧度,x的定义域为[-1.0,1.0],arccosx的值域为[0,π]。返回值:计算结果的双精度值。例程如下:求arccosx。#includestdio.h#includemath.hintmain(void){doubleresult;doublex=1.0;result=acos(x);printf(arccos%lf=%lf\n,x,result);return0;}例程说明:本例程应用函数acos计算1.0的反余弦值,即:arccos1。返回计算结果的双精度值。本例程的运行结果是:arccos1.000000=0.0000003.asin:反正弦函数函数原型:doubleasin(doublex);头文件:#includemath.h是否是标准函数:是函数功能:求x的反正弦值,这里,x为弧度,x的定义域为[-1.0,1.0],arcsinx值域为[-π/2,+π/2]。返回值:计算结果的双精度值。例程如下:求arcsinx。#includestdio.h#includemath.hintmain(void){doubleresult;doublex=1.0;result=asin(x);printf(arcsin%lfis%lf\n,x,result);return(0);}例程说明:本例程应用函数asin计算1.0的反正弦值,即:arcsin1。返回计算结果的双精度值。本例程的运行结果是:arcsin1.000000is1.5707964.atan:反正切函数函数原型:doubleatan(doublex);头文件:#includemath.h是否是标准函数:是函数功能:求x的反正切值,这里,x为弧度,x的定义域为(-∞,+∞),arctanx的值域为(-π/2,+π/2)。返回值:计算结果的双精度值。例程如下:求arctanx。#includestdio.h#includemath.hintmain(void){doubleresult;doublex=1.0;result=atan(x);printf(arctan%lf=%lf\n,x,result);return(0);}例程说明:本例程应用函数atan计算1.0的反正切值,即:arctan1。并返回计算结果的双精度值。本例程的运行结果是:arctan1.000000=0.7853985.atan2:反正切函数2函数原型:doubleatan2(doubley,doublex);头文件:#includemath.h是否是标准函数:是函数功能:求y/x的反正切值。返回值:计算结果的双精度值。例程如下:求arctan(x/y)。#includestdio.h#includemath.hintmain(void){doubleresult;doublex=10.0,y=5.0;result=atan2(y,x);printf(arctan%lf=%lf\n,(y/x),result);return0;}例程说明:本例程应用函数atan2计算10.0/5.0的反正切值,即:arctan0.5。并返回计算结果的双精度值。本例程的运行结果是:arctan0.500000=0.4636486.ceil:向上舍入函数函数原型:doubleceil(doublex);头文件:#includemath.h是否是标准函数:是函数功能:将双精度数x向上舍入,即:取它的最大整数。例如:ceil(123.4000