Модульное программирование в Турбо Паскале. Бакланов М.В - 6 стр.

UptoLike

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

- 6 -
ijh]jZffu ;he__lh]h_kebbaf_g_gby\g_k_gu\bgl_jn_ckgm xqZklvfh^meylh
[m^mli_j_dhfibebjh\ZgulZd`_b\k_^jm]b_fh^mebh[jZsZxsb_kydg_fm
< j_`bf_ BUILD kms_kl\mxsb_ TPU-nZceu b]ghjbjmxlky b kbkl_fZ
iulZ_lky hlukdb\Zlv b dhfibebjh\Zlv khhl \_lkl\mxsbc PAS-nZce ^ey dZ`^h]h
h[ty\e_ggh]h\ij_^eh`_gbbUSES fh^mey
5. Ijbf_j>hklmidh[ty\e_gguf\fh^me_h[t_dlZf
Kha^Zlvfh^mevj_Zebamxsbc kj_^kl\ZjZ[hlukdhfie_dkgufbqbkeZfb
Unit Cmplx;
Interfase
Type
Complex = record
re,im : real
end;
Procedure InitC (x,y: real; var z: Complex);
Procedure
AddC (x,y: Complex;
var
z: Complex);
Procedure SubC (x,y: Complex; var z: Complex);
Procedure MulC (x,y: Complex; var z: Complex);
Procedure DivC (x,y: Complex; var z: Complex);
Function EqvC (x,y: Complex): boolean;
Procedure WriteC (z : Complex);
Const
C: Complex = (re:0.1 ; im:-2)
Implementation
Procedure InitC;
begin
with
z
do
begin
re := x;
im :=y
end
end;
Procedure AddC;
begin
with z do
begin
re := x.re + y.re;
im := y.im + x.im
end
end;
                                        -6-
ijh]jZffu ;he__lh]h_kebbaf_g_gby\g_k_gu\bgl_jn_ckgmxqZklvfh^meylh
[m^mli_j_dhfibebjh\ZgulZd`_b\k_^jm]b_fh^mebh[jZsZxsb_kydg_fm
     < j_`bf_ BUILD kms_kl\mxsb_ TPU-nZceu b]ghjbjmxlky b kbkl_fZ
iulZ_lky hlukdb\Zlv b dhfibebjh\Zlv khhl\_lkl\mxsbc PAS-nZce ^ey dZ`^h]h
h[ty\e_ggh]h\ij_^eh`_gbbUSES fh^mey


            5. Ijbf_j>hklmidh[ty\e_gguf\fh^me_h[t_dlZf

     Kha^Zlvfh^mevj_Zebamxsbckj_^kl\ZjZ[hlukdhfie_dkgufbqbkeZfb

           Unit Cmplx;
           Interfase
             Type
               Complex = record
                            re,im : real
                         end;
             Procedure InitC (x,y: real;      var z: Complex);
             Procedure AddC    (x,y: Complex; var z: Complex);
             Procedure SubC    (x,y: Complex; var z: Complex);
             Procedure MulC    (x,y: Complex; var z: Complex);
             Procedure DivC    (x,y: Complex; var z: Complex);
             Function EqvC     (x,y: Complex): boolean;
             Procedure WriteC (z : Complex);

             Const
               C: Complex = (re:0.1 ; im:-2)

           Implementation

             Procedure InitC;
             begin
               with z do
               begin
                 re := x;
                 im :=y
               end
             end;

             Procedure AddC;
             begin
               with z do
               begin
                 re := x.re + y.re;
                 im := y.im + x.im
               end
             end;