asin数学函数应用实例

来源:互联网 发布:mac如何制作启动盘 编辑:程序博客网 时间:2024/04/29 13:46
头文件:#include <math.h>

定义函数:double asin (double x)

函数说明:asin()用来计算参数x 的反正弦值,然后将结果返回。参数x 范围为-1 至1 之间,超过此范围则会失败。

返回值:返回-PI/2 之PI/2 之间的计算结果。

错误代码:EDOM 参数x 超出范围。

注意,使用 GCC 编译时请加入-lm。

范例 

#include <stdio.h>#include <math.h>int main(){    double angle;    angle = asin (0.5);    printf("angle = %f\n", angle);    return 0;}
Makefile文件:

CXX=g++CFLAGS=-O3 -Wall -fmessage-length=0 -fPIC -DARCH_x86OBJS=asin.oLIBS+= TARGET= Tasin$(TARGET):$(OBJS)    $(CXX) -o $(TARGET) $(OBJS) $(CFLAGS) $(LIBS)    chmod 6755 $(TARGET)all:$(TARGET)install: all    chmod 6755 $(TARGET)clean:    rm -f $(OBJS) $(TARGET)

运行结果:

[root@localhost asin]# makemake: Warning: File `Makefile' has modification time 13 s in the futurecc -O3 -Wall -fmessage-length=0 -fPIC -DARCH_x86   -c -o asin.o asin.cg++ -o Tasin asin.o -O3 -Wall -fmessage-length=0 -fPIC -DARCH_x86 chmod 6755 Tasinmake: warning:  Clock skew detected.  Your build may be incomplete.[root@localhost asin]# ./Tasin angle = 0.523599



0 0
原创粉丝点击