.


:




:

































 

 

 

 





-

230102 -

230105

 

()

()

()

 

1,2,3

2,3,4,5

2006

 

 


, 230102 - , 230105 - , 27.03.2000 .

 

:

. . , ... ___________..

 

 

, .

 

:

, ..-.. _______________..

 

. . :

, ... _______________..

 

. . :

, ... _______________..

 

1. ... 4

2. .. 5

3. .. 6

3.1. . 6

3.2. . 10

3.3. . 13

3.4. .. 14

3.5. / . 16

3.6. . 16

3.7. .. 17

3.8. .. 18

3.9. .. 20

3.10. - . 22

3.11. - . 24

4. . 25

5. ... 27

5.1. . 27

5.2. 1. 27

5.3. 2. 31

6. . 32

6.1 1. 32

6.2 2. 32

6.3 3. 32

6.4 4. 32

6.5 5. 33

7. ... 34

7.1 . 34

7.2 . 34

8. - . 36

. 37

 

1.

 

- . , Object Pascal () Delphi, WINDOWS. .

 

2.

 

.

- 18

- 18

- 20

- 4

- 60

 

3,4

3

4

5

 

.

, .

( ).

, :

- ;

- -;

- ;

- , ;

- .

: 175 , 260 .

 

3.

3.1.

. Delphi - . - () () , . . : , , .. Delphi - - (Object Pascal). - , , . ( ) , [1-3].

, Windows . . . , , , .. . , , (, ).

, Delphi-.

Delphi. :

;

;

(Component Palette);

(Object Inspector);

;

(Code Editor).

Delphi: ( , . 1), - .

.1. Delphi

. : File, Edit, Search, View, Project, Run, Component, Database, Tools, Help (.1).

File . (New Application), (New Form New Unit), (Open Close), (Close All), , (Save, Save As, Save Project As, Save All). - (Alt+F11) Uses .

Edit (Align to Grid, Align), , (Bring to Front, Send to Back), (Size), (Scale) ..

Search (Find, Replace, Search Again, Incremental Search) . View . Project (Compile, Build All) (Syntax Check). Run . Component . Database . Tools .

.

. . (. 1). , . , . , , Shift - . , . , , .

. . , : (Properties) (Events) (. 2). , F11. : , - . (). . +, , +Font.

. , , - (), . , . () . .

(Width, Name ..) . (Align, Cursor ..) , . (Font, Picture, Glyph ..) , .

. - Windows, . . . . , . / . Shift , , . Delete. . , .

, . Edit=> Align ( View=> Alignment Palette ). - Left . , .

. , Delphi . :

*.dpr. Object Pascal,
. () ;

, : *.pas *.dfm. ;

*.res. , , , ;

*.dof;

*.drf, *.dsk, *.dsm. .

Delphi- ( Unitl.pas, Unit2.pas,...) (Projectl.dpr). . Delphi- : *.dpr, *.dfm, *.pas, *.res. .

. . . Unitl.pas, Forml, . (, , , ..). . () begin end. . end. , Unitl :

unit Unitl; { }

interface { }

uses { , }

Windows, Messages, SysUtils, Classes,Graphics, Controls, Forms, Dialogs;

 

type { , }

TForml = class (TForm)

Button 1: TButton;

procedure ButtonlClick(Sender: TObject);

private { }

public { }

end;

var { }

Forml: Tforml;

{ }

procedure ;

procedure ;

{ }

implementation

 

{$R *.DFM} { }

procedure TForml.ButtonlClick(Sender: Tobject);

begin

{ }

end;

end. { }

 

3.2.

. 60 - 70- .. . [1-3].

, (, ). ( ): , , .. , (), . , :

 

and mod else record
array nil end repeat
begin not file set
case of for then
const- or function to
div- Packed - Goto- type
do procedure- if until
Downto- program in var

 

:

- : boolean (), char (), integer (), real (), text ( ) ..;

- : false (), true (), maxint ( ), pi ( ) ..;

- : abs, arctan, cos, exp, In, sin ..;

- : read, readln, write, writeln, inc, dec ..

, , .

, (, ), , .., , _.

.

. Pascal :

 

program < >;

 

uses ;
label ;
const ;
type ;
var ;
procedure ;
function

Begin

< >

End.

() ;. (end.).

Delphi , . , , : ( MyName myname) .

. - , { }. . . //. . $. .

. . , .

, . , . Var :

var < 1>: < 1>;

< n>: < n>;

.

: . , . .

. .

, , . , , . , (:=).

:

Var a: integer;

Begin

a := 100;

End;

:

1. .

2. 3, 5.6, 8.95.

3. (Help) .

 

3.3.

. . , , . : ( , integer ,), ( , real - ), (char) (boolean) [1-3].

, , 5.04, -12.109, . -5.2+2 -520.0, 16.1-3 - 0.0161. +2 10 +2, -3 - 10-3,

 

NEm = N*10m

 

(char) - ASCII. - , , , '', '5', '%'.

(boolean) : false () true ().

( ) , . (succ, pred).

. , type. () type :

type < 1> = < 1>;

< n> = < n>

, .

() , , -, :

type < > = ( < 1>, < 2>,...,< n> );

.

( ):

type week = (mon, tue, wed, the, fri, sat, sun);

color = (red, green, yellow, white);

- day avto :

var day: week;

avto: color;

, , :

day:= fri; avto:= green; avto:= red.

0. ord, pred succ. ,

ord(avto) = 0, ord(day) = 4, pred(day) = the, succ(day) = sat.

.

. :

type < > = < 1>.. < 2>

. (weekdays, workdays, months), , . dayl, day2, day3 month :

Type weekdays = (mon, tue, wed, the, fri, sat, sun);

workdays = mon..fri;

months = 1..12;

var dayl, day2: weekdays;

day3: workdays;

month: months;

(string). , 255 . , . :

type t = string[10];

const s = 'Bye!';

var top: t; w: string;

.

:

const < 1>: < 1> = < 1>;

< n>: < > = < n>

:

const : char = ''; n: integer = 5; k: real = 1.73; F: Boolean=true;

:

1. .

2. .

3. , succ() pred()

4. , .

 

3.4.

, ( ) . , *, +, -, &, / .. : x+y.

. . , .

: , , , , , .. ( ) ( ), .

, () , . (+) (-). (+), (-), (*), (/), (div), (mod). Integer. , .

Boolean. : (not), (and), (or) (xor). , , . , X andY True(), , X Y True.

Delphi and or: ( ).

: (not), (and), (or), (xor), (shl), (shr). :

- not , ;

- and, or xor , .

(+), , (=, <>, <, >, <=, >=). .

. . , . : , True, False. . . , ASCII [1-3].

:

1. .

2. ? (a*k, ak)?

3. X :

x:= 10; x:= x+3;

4. : 20 div 6; 20 mod 6; round(6.9);

 

/ .

/ read write, DOS. Windows Delphi Edit Label .

Caption Label Text Edit ( string) , :

Label1.Caption:= ;

Label1 : . , . , integer, :

Label1.Caption:= IntToStr(a); //

b real, FloatToStr(b);

Edit Text. , Edit.Text string, :

Var a: integer; b: real;

begin

a:= strtoint(Edit1.text); //

b:= strtofloat(Edit2.text); //

end;

 

3.6.

. true () false (). . , , , not, and or. :

1- not, 2 - and, 3 - or

1 < < 5 : (1 < ) and (x < 5). < 1; > 5 : ( < 1) or (x > 5). , , .

if. if . : .

:

If < > then < 1> else < 2>;

. , 1, - 2. 1 2 .

: if a>0 then x:=a*b else X:=0;

if :

If < > then < 1>;

. 1 .

. =20.

if > 12 then := 2 * ;

z:= 10;

if x < 5 then z:= 10 + x / 2;

: y = 40, z = 10.

: GOTO, CASE.

:

1. GOTO CASE

2. , : X:= a or b and c;

3. ; .

4. : , b , a ≥ b ≥ c.

 

3.7.

. : , .

(for). for.

For < >: = < 1> to < 2> do < 1>;

, , , 1 2 .

. 1. (), 2, 1. , 2 . . , 2, .

. s = 0.

for i:= 4 to 6 do begins:= s + i; z:= 2 * i end;

s 0+4+5+6=15, z -12.

for:

for <>:= < 1> downto < 2> do < 1>;

, , -1.

!

(while). while :

while < > do < 1>;

. , 1. .

. , s = 4, s = 0.

while <= 8 do begin s:= s + x; x:= x + 1 end;

s=4+5+6+7+8= 30, x = 9.

:

1. x = 10! () .

2. 100 . .

3. S- , Delphi; , .

4. k- n.

3.8.

(array) - () , .

. - . , .

:

array [<>] of < >;

( ) .

type, const var. - .

. mymas, (-) zatraty mymas A, al mymas B, 7 , C 100 -.

type mymas = array [1..10] of real;

day = (mon, tue, wed, the, fri, sat, sun);

const zatraty: mymas =(1.2, 1, 1, 2, 8, 2.4, 8.7, 3, 7, 1.3);

var a, al: mymas;

b: array[day] of integer;

: array [1..100] of char;

. , := al al . . :

< > [ < > ]

( ) , , [1] - a, b[tue] - B.

. :

[1]:= 15.1;b[tue]:= 3; [1]:= V; [2]:= b

zatraty :

zatraty[l] = 1.2; zatraty[2] = 1;...; zatraty[10] =1.3.

. (5050) :

s:= 0;

for i:= 1 to 100 do

Begin

a[i]:= i;

s:= s + a[i]

end;

label1.caption:=inttostr(s);

for, while repeat , .

. . : , - , . , [1, 2] - .

- bal, 2 4 , sutki, 24 60 , 9 9 (.. 9*9=81 ).

const n = 9;

bal: array [1..2, 1..4] of integer=((4, 3, 5, 3), (4, 4, 5, 3));

var sutki: array [0..23] of array [0..59] of integer;

p: array [l..n, l..n] of integer;

bal :

bal[l, 1] = 4, bal[l, 2] = 3,..., bal[2, 3] - 5, bal[2, 4] = 3.

:

sutki[16][20]:=5; sutki[16,20]:=5;

 

:

1. ? ?

2. ( )?

3. -.

4. , :

var A,B: array[1..15,0..8] of real; t: Boolean;?

) A:= B; ) A:= A + B; ) t:= A <> B; ) A[1]:= B[1]; ) A[1]:= A[15];

) A[2,3]:= B[4][8] + B[1,1];

 

3.9.

. , , :

  • , ;
  • , ;
  • , ( ).

, . ( , ) ( ). . , .

, " ". , , . , , "", . . , , ( ), - "" , , . , "", . , , . , , , . , - , .

. - . , . , . , - ( ). .

:

- (), ;

- , () , ;

- ( ), , .

, , , .

:

Procedure <> ( < > ); [< >];

< >;

Begin

< >

end;

:

Function <> ( < > ): < >; [<>];

< >;

Begin

< , :

:= >

end;

 

, . , . .

Object Pascal : .

. , , . .

, , , . .

, , . .

. () . , :

MyProc(3, 6);

:

X:= Myfunc(3, 6);

.

 

:

1. . .

2. .

3. ?





:


: 2016-10-30; !; : 436 |


:

:

, .
==> ...

1705 - | 1576 -


© 2015-2024 lektsii.org - -

: 0.274 .