王朝知道
分享
 
 
 

求math数学库(pascal的)

王朝知道·作者佚名  2010-01-18  
宽屏版  字体: |||超大  
 
分类: 教育/科学 >> 学习帮助
 
参考答案:

Math库实用汇总

在FP中,Math库为我们提供了丰富的数学函数。以下介绍在OI中可能会用到的Math库中一些函数、过程。

使用方法:在程序头用Uses语句加载Math库

例子:

Program Ex_Math;

Uses Math;

Begin

Writeln(hypot(3,4));

End.

函数介绍:

 hypot

原型:function hypot(x:float;y:float):float

功能:返回直角三角形中较长边的长度,也就是sqrt(sqr(x)+sqr(y))

 ceil

原型:function ceil(x:float):Integer

功能:返回比参数大的最小整数

引发错误:在x超出Integer的范围时会引发溢出错误

 floor

原型:function floor(x:float):Integer

功能:返回参数小的最大整数

引发错误:在x超出Integer的范围时会引发溢出错误

 power

原型:function power(base:float;exponent:float):float

功能:返回base的exponent次方

引发错误:在base为负数且exponent为小数时

 intpower

原型:function intpower(base:float;const exponent:Integer):float

功能:返回base的exponent次方

 ldexp

原型:function ldexp(x:float;const p:Integer):float

功能:返回2的p次方乘以x

 log10

原型:function log10(x:float):float

功能:返回x的常用对数

 log2

原型:function log2(x:float):float

功能:返回x以2为底的对数

 logn

原型:function logn(n:float;x:float):float

功能:返回x以n为底的对数

 Max

原型:function Max(a:Integer;b:Integer):Integer

function Max(a:Int64;b:Int64):Int64

function Max(a:Extended;b:Extended):Extended

功能:返回a与b中较大的一个

 Min

原型:function Min(a:Integer;b:Integer):Integer

function Min(a:Int64;b:Int64):Int64

function Min(a:Extended;b:Extended):Extended

功能:返回a与b中较小的一个

 arcsin

原型:function arcsin(x:float):float

功能:返回x的反正弦值,返回的是弧度指单位

 arccos

原型:function arccos(x:float):float

功能:返回x的反余弦值,返回的是弧度指单位

 tan

原型:function tan(x:float):float

功能:返回x的正切值,x以弧度为单位

 cotan

原型:function cotan(x:float):float

功能:返回x的余切值,x以弧度为单位

 arcsinh

原型:function arcsinh(x:float):float

功能:返回双曲线的反正弦

 arccosh

原型:function arccosh(x:float):float

功能:返回双曲线的反余弦

 arctanh

原型:function arctanh(x:float):float

功能:返回双曲线的反正切

 sinh

原型:function sinh(x:float):float

功能:返回双曲线的正弦

 cosh

原型:function sinh(x:float):float

功能:返回双曲线的正弦

 tanh

原型:function sinh(x:float):float

功能:返回双曲线的正切

 cycletorad

原型:function cycletorad(cycle:float):float

功能:返回圆的份数转换成弧度之后的值

 degtorad

原型:function degtorad(deg:float):float

功能:返回角度转换成弧度之后的值

 radtocycle

原型:function radtocycle(rad:float):float

功能:返回弧度转换成圆的份数之后的值

 radtodeg

原型:function radtodeg(rad:float):float

功能:返回弧度转换成角度之后的值

 MaxValue

原型:function maxvalue(const data:Array[] of float):float

function maxvalue(const data:Array[] of Integer):Integer

function maxvalue(const data:PFloat;const N:Integer):float

function maxvalue(const data:PInteger;const N:Integer):Integer

功能:返回数组中的最大值

 MinValue

原型:function minvalue(const data:Array[] of float):float

function minvalue(const data:Array[] of Integer):Integer

function minvalue(const data:PFloat;const N:Integer):float

function MinValue(const Data:PInteger;const N:Integer):Integer

功能:返回数组中的最小值

 sum

原型:function sum(const data:Array[] of float):float

function sum(const data:PFloat;const N:LongInt):float

功能:求数组中所有数之和

 sumsandsquares

原型:procedure sumsandsquares(const data:Array[] of float;var sum:float;

var sumofsquares:float)

procedure sumsandsquares(const data:PFloat;const N:Integer;

var sum:float;var sumofsquares:float)

功能:将数组中的数求和放入num中,求平方和放入sumofsquares中

 **

原型:function operator **(float,float):float(bas:float;expo:float):float

function operator **(Int64,Int64):Int64(bas:Int64;expo:Int64):Int64

功能:同等于Power,这是乘方的操作符

例子:(注:以下全都在已经uses math的前提下进行的。)

begin

Writeln(hypot(6,8)); //输出10。10^2=6^2+8^2

end.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=―

begin

writeln(ceil(3.4));//4

writeln(ceil(3.7));//4

writeln(ceil(-3.4));//-3

writeln(ceil(-3.7));//-3

writeln(floor(3.4));//3

writeln(floor(3.7));//3

writeln(floor(-3.4));//-4

writeln(floor(-3.7));//-4

end.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=―

begin

writeln(power(1.1,1.1):2:3);

writeln(power(-1.1,3):2:3);

writeln(power(1.1,-1.1):2:3);

writeln(2**3);

writeln(1.1**(-1.1):2:3);

writeln(intpower(1.1,2):2:3);

writeln(intpower(4.1,-2):2:3);

writeln(intpower(-1.1,2):2:3);

writeln(ldexp(2,4):8:4); // 32.0000

writeln(ldexp(0.5,3):8:4);// 4.0000

writeln(ldexp(-3,3):8:4); // -24.000

Writeln(Log10(10):8:4);

Writeln(Log10(1):8:4);

Writeln(Log10(0.1):8:4);

Writeln(Log2(4):8:4);

Writeln(Log2(0.5):8:4);

Writeln(Logn(3,4):8:4);

Writeln(Logn(exp(1),exp(1)):8:4);

writeln(max(1,2));

writeln(min(1,2));

end.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=―

begin

writeln(arccos(0.5)/pi);

writeln(arcsin(0.5)/pi);

writeln(arctan(0.5)/pi); //这个不在math库里,在system库里就有

writeln(cos(pi/6)); //这个不在math库里,在system库里就有

writeln(sin(pi/6)); //这个不在math库里,在system库里就有

writeln(tan(pi/6));

writeln(cotan(pi/6));

end.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=―

begin

//返回的是双曲线的 | 定义域

writeln(arcosh(2));//反余弦 | [R]

writeln(arsinh(2));//反正弦 | [R]

writeln(artanh(0.1));//反正切 | [-1,1]

writeln(cosh(2));//余弦 | [R]

writeln(sinh(2));//正弦 | [R]

writeln(tanh(2));//正切 | [R]

end.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=―

begin

//角度、弧度、圆的相互转换,圆是指这么大的角占多少个圆

writeln(cycletorad(1/6)/pi);//圆到弧度

writeln(degtorad(90)/pi);//角度到弧度

writeln(radtocycle(pi/2));//弧度到圆

writeln(radtodeg(pi/3));//弧度到角度

end.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=―

Var

I:Integer;

a:array[1..10] of float;//一定要是longint或float,就是32为变量

begin

Randomize ;

for I:=low(a) to high (a) do begin

a[i]:=random(10);

write(a[i]:2:2,' ');

end;

writeln;

writeln(MaxValue(a):2:2);//数组中的最大值

writeln(MinValue(a):2:2);//数组中的最小值

writeln(sum(a):2:2);//数组中所有元素的和,只有float能用

sumsandsquares(a,s,ss);//s为和,ss为平方和,只有float能用

writeln(s:2:2,' ',ss:2:2);

end.

小贴士:① 若网友所发内容与教科书相悖,请以教科书为准;② 若网友所发内容与科学常识、官方权威机构相悖,请以后者为准;③ 若网友所发内容不正确或者违背公序良俗,右下举报/纠错。
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
如何用java替换看不见的字符比如零宽空格​十六进制U+200B
 干货   2023-09-10
网页字号不能单数吗,网页字体大小为什么一般都是偶数
 干货   2023-09-06
java.lang.ArrayIndexOutOfBoundsException: 4096
 干货   2023-09-06
Noto Sans CJK SC字体下载地址
 干货   2023-08-30
window.navigator和navigator的区别是什么?
 干货   2023-08-23
js获取referer、useragent、浏览器语言
 干货   2023-08-23
oscache遇到404时会不会缓存?
 干货   2023-08-23
linux下用rm -rf *删除大量文件太慢怎么解决?
 干货   2023-08-08
刀郎新歌破世界纪录!
 娱乐   2023-08-01
js实现放大缩小页面
 干货   2023-07-31
生成式人工智能服务管理暂行办法
 百态   2023-07-31
英语学习:过去完成时The Past Perfect Tense举例说明
 干货   2023-07-31
Mysql常用sql命令语句整理
 干货   2023-07-30
科学家复活了46000年前的虫子
 探索   2023-07-29
英语学习:过去进行时The Past Continuous Tense举例说明
 干货   2023-07-28
meta name="applicable-device"告知页面适合哪种终端设备:PC端、移动端还是自适应
 干货   2023-07-28
只用css如何实现打字机特效?
 百态   2023-07-15
css怎么实现上下滚动
 干货   2023-06-28
canvas怎么画一个三角形?
 干货   2023-06-28
canvas怎么画一个椭圆形?
 干货   2023-06-28
canvas怎么画一个圆形?
 干货   2023-06-28
canvas怎么画一个正方形?
 干货   2023-06-28
中国河南省郑州市金水区蜘蛛爬虫ip大全
 干货   2023-06-22
javascript简易动态时间代码
 干货   2023-06-20
感谢员工的付出和激励的话怎么说?
 干货   2023-06-18
 
>>返回首页<<
 
 
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
© 2005- 王朝网络 版权所有