PASCALMath庫實用匯總_第1頁
PASCALMath庫實用匯總_第2頁
PASCALMath庫實用匯總_第3頁
PASCALMath庫實用匯總_第4頁
PASCALMath庫實用匯總_第5頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、Math庫實用匯總在FP中,Math庫為我們提供了豐富的數(shù)學(xué)函數(shù)。以下介紹在OI中可能會用到的Math庫中一些函數(shù)、過程。使用方法:在程序頭用Uses語句加載Math庫例子:Program Ex_Math;Uses Math;BeginWriteln(hypot(3,4);End.函數(shù)介紹:hypot原型:function hypot(x:float;y:float):float功能:返回直角三角形中較長邊的長度,也就是sqrt(sqr(x)+sqr(y)ceil原型:function ceil(x:float):Integer功能:返回比參數(shù)大的最小整數(shù)引發(fā)錯誤:在x超出Integer的范圍

2、時會引發(fā)溢出錯誤floor原型:function floor(x:float):Integer功能:返回參數(shù)小的最大整數(shù)引發(fā)錯誤:在x超出Integer的范圍時會引發(fā)溢出錯誤power原型:function power(base:float;exponent:float):float功能:返回base的exponent次方引發(fā)錯誤:在base為負(fù)數(shù)且exponent為小數(shù)時intpower原型:function intpower(base:float;const exponent:Integer):float功能:返回base的exponent次方ldexp原型:function ldexp(

3、x:float;const p:Integer):float功能:返回2的p次方乘以xlog10原型:function log10(x:float):float功能:返回x的常用對數(shù)log2原型:function log2(x:float):float功能:返回x以2為底的對數(shù)logn原型:function logn(n:float;x:float):float功能:返回x以n為底的對數(shù)Max原型:function Max(a:Integer;b:Integer):Integerfunction Max(a:Int64;b:Int64):Int64function Max(a:Extended

4、;b:Extended):Extended功能:返回a與b中較大的一個Min原型:function Min(a:Integer;b:Integer):Integerfunction Min(a:Int64;b:Int64):Int64function Min(a:Extended;b:Extended):Extended功能:返回a與b中較小的一個arcsin原型:function arcsin(x:float):float功能:返回x的反正弦值,返回的是弧度指單位arccon原型:function arccon(x:float):float功能:返回x的反余弦值,返回的是弧度指單位tan原型

5、: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功能:返回

6、雙曲線的正弦cosh原型:function sinh(x:float):float功能:返回雙曲線的正弦tanh原型:function sinh(x:float):float功能:返回雙曲線的正切cycletorad原型:function cycletorad(cycle:float):float功能:返回圓的份數(shù)轉(zhuǎn)換成弧度之后的值degtorad原型:function degtorad(deg:float):float功能:返回角度轉(zhuǎn)換成弧度之后的值radtocycle原型:function radtocycle(rad:float):float功能:返回弧度轉(zhuǎn)換成圓的份數(shù)之后的值radto

7、deg原型:function radtodeg(rad:float):float功能:返回弧度轉(zhuǎn)換成角度之后的值MaxValue原型:function maxvalue(const data:Array of float):floatfunction maxvalue(const data:Array of Integer):Integerfunction maxvalue(const data:PFloat;const N:Integer):floatfunction maxvalue(const data:PInteger;const N:Integer):Integer功能:返回數(shù)組中的

8、最大值MinValue原型:function minvalue(const data:Array of float):floatfunction minvalue(const data:Array of Integer):Integerfunction minvalue(const data:PFloat;const N:Integer):floatfunction MinValue(const Data:PInteger;const N:Integer):Integer功能:返回數(shù)組中的最小值sum原型:function sum(const data:Array of float):floa

9、tfunction sum(const data:PFloat;const N:LongInt):float功能:求數(shù)組中所有數(shù)之和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)功能:將數(shù)組中的數(shù)求和方如num中,求平方和放入sumofsqua

10、res中例子:(注:以下全都在已經(jīng)uses math的前提下進(jìn)行的。)begin Writeln(hypot(6,8); /輸出10。102=62+82end.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);/-4end.begin writeln(power(1.1,1.1):2:

11、3); writeln(power(-1.1,3):2:3); writeln(power(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)

12、: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); /這

13、個不在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);/正切 | Rend.begin /角度、弧度、圓的相互轉(zhuǎn)換,圓是指這么大的角占多少個圓 writeln(cycletorad(1/6)/pi);/圓到弧度 writeln(degtorad(90)/pi);/角度到弧度 writeln(radtocycle(pi/2);/弧度到圓 writeln(radtodeg(pi/3);/弧度到角度end.Var I:Integer; a:array1.10 of float;/一定要是longint或float,就是32為變量begin Randomize ; for I:=low(a) to high (a) do begin ai:=random

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論