Введение в технологию программирования. Ч.1. Среда объектно-ориентированного программирования Delphi. Коржов Е.Н - 78 стр.

UptoLike

Составители: 

78
ɉɪɢɥɨɠɟɧɢɟ 3. Ɉɫɧɨɜɧɵɟ ɦɚɬɟɦɚɬɢɱɟɫɤɢɟ ɮɭɧɤɰɢɢ
Ɍɚɛɥɢɰɚ 3.1
Ɉɫɧɨɜɧɵɟ ɦɚɬɟɦɚɬɢɱɟɫɤɢɟ ɮɭɧɤɰɢɢ
Ɏɭɧɤɰɢɹ Ɂɧɚɱɟɧɢɟ
Abs(n) Ⱥɛɫɨɥɸɬɧɨɟ ɡɧɚɱɟɧɢɟ n
Sqrt(n) Ʉɜɚɞɪɚɬɧɵɣ ɤɨɪɟɧɶ ɢɡ n
Sqr(n) Ʉɜɚɞɪɚɬ n
Exp(n) ɗɤɫɩɨɧɟɧɬɚ n
Ln(n) ɇɚɬɭɪɚɥɶɧɵɣ ɥɨɝɚɪɢɮɦ n
Rardom(n) ɋɥɭɱɚɣɧɨɟ ɰɟɥɨɟ ɱɢɫɥɨ ɜ ɞɢɚɩɚɡɨɧɟ ɨɬ 0 ɞɨ n–1 (ɩɟɪɟɞ
ɩɟɪɜɵɦ ɨɛɪɚɳɟɧɢɟɦ ɤ ɮɭɧɤɰɢɢ ɧɟɨɛɯɨɞɢɦɨ ɜɵɡɜɚɬɶ
ɮɭɧɤɰɢɸ Randomize, ɤɨɬɨɪɚɹ ɜɵɩɨɥɧɢɬ ɢɧɢɰɢɚɥɢɡɚɰɢɸ
ɩɪɨɝɪɚɦɦɧɨɝɨ ɝɟɧɟɪɚɬɨɪɚ ɫɥɭɱɚɣɧɵɯ ɱɢɫɟɥ)
Sin(a) ɋɢɧɭɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɚ
Cos(a) Ʉɨɫɢɧɭɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ a
Arctan(a) Ⱥɪɤɬɚɧɝɟɧɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɚ
ArcCos(X) Ⱥɪɤɤɨɫɢɧɭɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɏ
ArcSin(X) Ⱥɪɤɫɢɧɭɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɏ
Cotan(X) Ʉɨɬɚɧɝɟɧɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɏ
Tan(X) Ɍɚɧɝɟɧɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɏ
LogN(Base, X) Ʌɨɝɚɪɢɮɦ ɨɬ X ɩɪɢ ɨɫɧɨɜɚɧɢɢ Base
Power(Base,X) ȼɨɡɜɟɞɟɧɢɟ ɱɢɫɥɚ Base ɜ ɫɬɟɩɟɧɶ X
ɉɨɫɥɟɞɧɢɟ ɩɹɬɶ ɮɭɧɤɰɢɣ ɫɬɚɧɨɜɹɬɫɹ ɞɨɫɬɭɩɧɵɦɢ ɩɪɨɝɪɚɦɦɟ ɬɨɥɶɤɨ
ɩɨɫɥɟ ɫɫɵɥɤɢ ɧɚ ɦɨɞɭɥɶ Math ɩɨɫɥɟ SysUtils ɜ ɩɪɟɞɥɨɠɟɧɢɢ uses.
ȼɫɟ ɮɭɧɤɰɢɢ ɢ ɜɯɨɞɹɳɢɟ ɜ ɧɢɯ ɩɟɪɟɦɟɧɧɵɟ ɢɦɟɸɬ ɬɢɩ Extended.
ȼɟɥɢɱɢɧɚ ɭɝɥɚ ɬɪɢɝɨɧɨɦɟɬɪɢɱɟɫɤɢɯ ɮɭɧɤɰɢɣ ɞɨɥɠɧɚ ɛɵɬɶ ɜɵɪɚɠɟɧɚ ɜ ɪɚ-
ɞɢɚɧɚɯ. Ⱦɥɹ ɩɪɟɨɛɪɚɡɨɜɚɧɢɹ ɜɟɥɢɱɢɧɵ ɭɝɥɚ ɢɡ ɝɪɚɞɭɫɨɜ ɜ ɪɚɞɢɚɧɵ ɢɫɩɨɥɶ-
ɡɭɟɬɫɹ ɮɨɪɦɭɥɚ (ɚ × 3,1415256) /180, ɝɞɟ ɚɜɟɥɢɱɢɧɚ ɭɝɥɚ ɜ ɝɪɚɞɭɫɚɯ;
3,1415926 – ɱɢɫɥɨ «ɉɂ». ȼɦɟɫɬɨ ɤɨɧɫɬɚɧɬɵ 3,1415926 ɦɨɠɧɨ ɢɫɩɨɥɶɡɨɜɚɬɶ
ɫɬɚɧɞɚɪɬɧɭɸ ɢɦɟɧɨɜɚɧɧɭɸ ɤɨɧɫɬɚɧɬɭ pi.
ɉɪɢɥɨɠɟɧɢɟ 4. Ƚɪɚɮɢɱɟɫɤɢɣ ɢɧɫɬɪɭɦɟɧɬɚɪɢɣ
Ʉɥɚɫɫ TFont
ɋ ɩɨɦɨɳɶɸ ɤɥɚɫɫɚ TFont ɫɨɡɞɚɟɬɫɹ ɨɛɴɟɤɬ-ɲɪɢɮɬ ɞɥɹ ɥɸɛɨɝɨ ɝɪɚ-
ɮɢɱɟɫɤɨɝɨ ɭɫɬɪɨɣɫɬɜɚ (ɷɤɪɚɧɚ, ɩɪɢɧɬɟɪɚ, ɩɥɨɬɬɟɪɚ ɢ ɬ. ɩ.). Ɉɫɧɨɜɧɵɟ ɫɜɨɣ-
ɫɬɜɚ ɤɥɚɫɫɚ ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 7.1.
                   ɉɪɢɥɨɠɟɧɢɟ 3. Ɉɫɧɨɜɧɵɟ ɦɚɬɟɦɚɬɢɱɟɫɤɢɟ ɮɭɧɤɰɢɢ
                                                           Ɍɚɛɥɢɰɚ 3.1
                     Ɉɫɧɨɜɧɵɟ ɦɚɬɟɦɚɬɢɱɟɫɤɢɟ ɮɭɧɤɰɢɢ
    Ɏɭɧɤɰɢɹ                           Ɂɧɚɱɟɧɢɟ
 Abs(n)         Ⱥɛɫɨɥɸɬɧɨɟ ɡɧɚɱɟɧɢɟ n
 Sqrt(n)        Ʉɜɚɞɪɚɬɧɵɣ ɤɨɪɟɧɶ ɢɡ n
 Sqr(n)         Ʉɜɚɞɪɚɬ n
 Exp(n)         ɗɤɫɩɨɧɟɧɬɚ n
 Ln(n)          ɇɚɬɭɪɚɥɶɧɵɣ ɥɨɝɚɪɢɮɦ n
 Rardom(n)      ɋɥɭɱɚɣɧɨɟ ɰɟɥɨɟ ɱɢɫɥɨ ɜ ɞɢɚɩɚɡɨɧɟ ɨɬ 0 ɞɨ n–1 (ɩɟɪɟɞ
                ɩɟɪɜɵɦ ɨɛɪɚɳɟɧɢɟɦ ɤ ɮɭɧɤɰɢɢ ɧɟɨɛɯɨɞɢɦɨ ɜɵɡɜɚɬɶ
                ɮɭɧɤɰɢɸ Randomize, ɤɨɬɨɪɚɹ ɜɵɩɨɥɧɢɬ ɢɧɢɰɢɚɥɢɡɚɰɢɸ
                ɩɪɨɝɪɚɦɦɧɨɝɨ ɝɟɧɟɪɚɬɨɪɚ ɫɥɭɱɚɣɧɵɯ ɱɢɫɟɥ)
 Sin(a)         ɋɢɧɭɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɚ
 Cos(a)         Ʉɨɫɢɧɭɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ a
 Arctan(a)      Ⱥɪɤɬɚɧɝɟɧɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɚ
 ArcCos(X)      Ⱥɪɤɤɨɫɢɧɭɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɏ
 ArcSin(X)      Ⱥɪɤɫɢɧɭɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɏ
 Cotan(X)       Ʉɨɬɚɧɝɟɧɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɏ
 Tan(X)         Ɍɚɧɝɟɧɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɏ
 LogN(Base, X) Ʌɨɝɚɪɢɮɦ ɨɬ X ɩɪɢ ɨɫɧɨɜɚɧɢɢ Base
 Power(Base,X) ȼɨɡɜɟɞɟɧɢɟ ɱɢɫɥɚ Base ɜ ɫɬɟɩɟɧɶ X
      ɉɨɫɥɟɞɧɢɟ ɩɹɬɶ ɮɭɧɤɰɢɣ ɫɬɚɧɨɜɹɬɫɹ ɞɨɫɬɭɩɧɵɦɢ ɩɪɨɝɪɚɦɦɟ ɬɨɥɶɤɨ
ɩɨɫɥɟ ɫɫɵɥɤɢ ɧɚ ɦɨɞɭɥɶ Math ɩɨɫɥɟ SysUtils ɜ ɩɪɟɞɥɨɠɟɧɢɢ uses.
      ȼɫɟ ɮɭɧɤɰɢɢ ɢ ɜɯɨɞɹɳɢɟ ɜ ɧɢɯ ɩɟɪɟɦɟɧɧɵɟ ɢɦɟɸɬ ɬɢɩ Extended.
ȼɟɥɢɱɢɧɚ ɭɝɥɚ ɬɪɢɝɨɧɨɦɟɬɪɢɱɟɫɤɢɯ ɮɭɧɤɰɢɣ ɞɨɥɠɧɚ ɛɵɬɶ ɜɵɪɚɠɟɧɚ ɜ ɪɚ-
ɞɢɚɧɚɯ. Ⱦɥɹ ɩɪɟɨɛɪɚɡɨɜɚɧɢɹ ɜɟɥɢɱɢɧɵ ɭɝɥɚ ɢɡ ɝɪɚɞɭɫɨɜ ɜ ɪɚɞɢɚɧɵ ɢɫɩɨɥɶ-
ɡɭɟɬɫɹ ɮɨɪɦɭɥɚ (ɚ × 3,1415256) /180, ɝɞɟ ɚ – ɜɟɥɢɱɢɧɚ ɭɝɥɚ ɜ ɝɪɚɞɭɫɚɯ;
3,1415926 – ɱɢɫɥɨ «ɉɂ». ȼɦɟɫɬɨ ɤɨɧɫɬɚɧɬɵ 3,1415926 ɦɨɠɧɨ ɢɫɩɨɥɶɡɨɜɚɬɶ
ɫɬɚɧɞɚɪɬɧɭɸ ɢɦɟɧɨɜɚɧɧɭɸ ɤɨɧɫɬɚɧɬɭ pi.




                         ɉɪɢɥɨɠɟɧɢɟ 4. Ƚɪɚɮɢɱɟɫɤɢɣ ɢɧɫɬɪɭɦɟɧɬɚɪɢɣ

     Ʉɥɚɫɫ TFont
      ɋ ɩɨɦɨɳɶɸ ɤɥɚɫɫɚ TFont ɫɨɡɞɚɟɬɫɹ ɨɛɴɟɤɬ-ɲɪɢɮɬ ɞɥɹ ɥɸɛɨɝɨ ɝɪɚ-
ɮɢɱɟɫɤɨɝɨ ɭɫɬɪɨɣɫɬɜɚ (ɷɤɪɚɧɚ, ɩɪɢɧɬɟɪɚ, ɩɥɨɬɬɟɪɚ ɢ ɬ. ɩ.). Ɉɫɧɨɜɧɵɟ ɫɜɨɣ-
ɫɬɜɚ ɤɥɚɫɫɚ ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 7.1.


                                   78