分享
 
 
 

求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.

小贴士:① 若网友所发内容与教科书相悖,请以教科书为准;② 若网友所发内容与科学常识、官方权威机构相悖,请以后者为准;③ 若网友所发内容不正确或者违背公序良俗,右下举报/纠错。
 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有