.


:




:

































 

 

 

 


If a[i]>a[j] then begin




t:=a[i];

a[i]:=a[j];

a[j]:=t;

end;

for i:=1 to N do

StringGrid2.Cells[i-1,0]:=IntToStr(a[i]);

FreeMem(a,N*sizeof(integer));

end;

end.

5.4.

). . 4.6 .

). . . . StringGrid1. , , StringGrid2, Edit1.

1. , . .

2. , . : , , .

3. , . , .

4. , . (.. ).

5. , . k .

6. , . n .

7. , . : , , , , .

8. X Y Z , .

9. , . , , .. .

10. . , .

11. X (.. , : xi >xj i<j).

12. . , .

13. , . .

14. , . .

15. , . .

 


 

6.

: DELPHI . , UNIT .

6.1.

, .

.

:

Procedure < > ([

]);

Const [ ];

Type [ ];

Var [ ];

Begin

//

End;

: < > ([ ]);

, :

Function < > ([

]): < >;

Const [ ];

Type [ ];

Var [ ];

Begin

//

Result:= ;// Result

// < >:= ;

End; //

: y:=< > ([ ]);

. :

Type <> = function ([ ]):< ->;

Type <> = procedure ([ ]);.

. . , . : -, -, -. -. - , , . - -. - ( Var) - ( const) ( ) . , -. - , .. . , -.

6.2.

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

Unit , . Uses .

interface implementation , .

implementation , . , , , , .

initialization , ( ).

finalization ( ).

6.3.

: , . .

 

. 6.1

6.3.1.

Delphi , . File New Unit. Unit Unit2. , , Unit Matfu. ( Matfu.pas). , .

6.3.2.

, Project Add to Project , . Uses MatFu. , .

(. 6.1).

( 6.1) ( 6.2) ( . . 3.3).

6.1

unit matfu;

Interface

uses StdCtrls, SysUtils;

Type

fun = function (x: extended):extended; //

{ f ( )}

procedure Tabl(f:fun;xn,xk:extended; m: word; Mem1: TMemo);

Implementation

procedure Tabl;

var x,y,h: extended;

i: integer;

Begin

x:=xn; h:=(xn-xk)/m;

for i:=1 to m+1 do begin

y:=f(x);

Mem1.Lines.Add(' x='+FloatToStrf(x,fffixed,8,3)+

' y='+FloatToStrf(y,fffixed,8,3));

x:=x+h;

end;

end;

end. // matfu

6.2

unit Unit6;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, Buttons, ExtCtrls, Matfu;

type

TForm1 = class(TForm)

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Edit1: TEdit;

Edit2: TEdit;

Edit3: TEdit;

Edit4: TEdit;

RadioGroup1: TRadioGroup;

Memo1: TMemo;

BitBtn1: TBitBtn;

BitBtn2: TBitBtn;

procedure FormCreate(Sender: TObject);

procedure BitBtn1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

xn,xk,e: extended;

m: word;

implementation

{$R *.dfm}

 

function sx(x:extended):extended;

var a,n,s: extended;

k: integer;

begin

k:=-1; a:=1; n:=0; s:=1;

try

while (abs(a) > e) do begin

n:=n+1;

a:=-a*x/n;

s:=s+a;

end;

Result:=s;

except

on EInvalidOp do

k:=MessageDlg(' . +

?',mtError,[mbYes,mbNo],0);

on EOverFlow do

k:=MessageDlg(' - +

! ?',mtError,[mbYes,mbNo],0);

else

k:=MessageDlg(' !+

?',mtError,[mbYes,mbNo],0);

end;

case k of

mrYes: Result:=0;

mrNo: Halt(1);

end;

end;

 

function yx(x:extended):extended;

begin

Result:=exp(-x);

end;

 

procedure TForm1.FormCreate(Sender: TObject);

begin

Memo1.Clear;

RadioGroup1.ItemIndex:=0;

Edit1.Text:='0';

Edit2.Text:='2';

Edit3.Text:='6';

Edit4.Text:='0,001';

end;

 

procedure TForm1.BitBtn1Click(Sender: TObject);

begin

Memo1.Clear;

Memo1.Lines.Add('. . 6 . . 552003 ..');

xn:=StrToFloat(Edit1.Text);

Memo1.Lines.Add(' xn='+FloatToStrF(xn,ffFixed,6,2));

xk:=StrToFloat(Edit2.Text);

Memo1.Lines.Add(' xk='+FloatToStrF(xk,ffFixed,6,2));

m:=StrToInt(Edit3.Text);

Memo1.Lines.Add(' h='+IntToStr(m));

e:=StrToFloat(Edit4.Text);

Memo1.Lines.Add(' e='+FloatToStrF(e,ffFixed,8,5));

case RadioGroup1.ItemIndex of

0: begin

Memo1.Lines.Add(' S(x)');

Tabl(sx,xn,xk,m,Memo1);

end;

1: begin

Memo1.Lines.Add(' Y(x)');

Tabl(yx,xn,xk,m,Memo1);

end;

end;

end;

end.

6.4.

, 3. .


 

7. C . .

: . .

7.1.

, . R -

, p . p. p . 09, A, B, C, D, E, F 10, 11, 12, 13, 14, 15.

: , . , . .

, .

, , , . , . , , .

. , . .

7.2

, .

set of:

type < >= set of < >;

var A,B,C: ;

< > - Word, Integer, Longint, .. (, , char, byte, boolean).

-: [i1, i2, , ik], ik .

7.2.1

, , .

Include (S, i); - S i, ;

Exclude (S, i); - S i, .

, s:=s+[i]; s:=s-[i];

c=d true ;

c< > d true ;

c>=d true d ;

c<=d true d;

i in c true i .

7.2.2

1. n :

......

Var A:set of char;

s:char;

n:Word;

Begin

A:=[ ]; //

for i:=1 to n do begin

read(s);

A:=A+[s];

end;

end.

2. :

......

Var B:set of 1..100;

k:byte;

Begin

for k:=1 to 100 do if k in B then Write(k);

......

end.

3. if:

if (k=5) or (k=1) or (k=8) then.... :

if k in [5,1,8] then....

7.3.

:

Var

s1: String[N]; // , N £ 255

s2: ShortString; // , N = 255

s3: String; // , N £ 2

s4: WideString; //

s5: PChar; // -

. String[N] nt (0≤nt≤255) . String[N] N+1 . s1[0] . ShortString String[255].

String. , String[N] () . .

WideString. , OLE-. String , , .

- PChar. , #0. . - API- Windows (API Application Program Interface ).

, : s[i]:=s[j].

: , (s:=s1+ fg+s2), (>, ³, =, <, ≤). , (, , ) .

7.4

:

Delete(St:String; pz,n:integer); - n pz.

Insert(St,St1;string;pz:integer); - St St1 pz.

:

St:=Copy(St1,pz,n); - St1 St n pz, St1 .

N:=Length(St); - .

pz:=pos(St,St1); - , St1 St, St1 St pz=0.

1.

7.5

: . . Enter.

(. 7.1).

. 7.1

7.1.

7.1.

unit Unit7;

Interface

Uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,

Forms, Dialogs, StdCtrls;

Type

TForm1 = class (TForm)

Edit1: TEdit;

Label2: TLabel;

Edit2: TEdit;

Label1: TLabel;

procedure FormCreate(Sender: TObject);

procedure Edit1KeyPress(Sender: TObject; var Key: Char);

private { Private declarations }

public { Public declarations }

end;

var Form1: TForm1;

Implementation

{$R *.dfm}

 

Function Krz(St:string):Word; // - x

Var a: set of char;

m,i: Word;

Begin

m:=0; a:=[];

for i:=1 to Length(St do





:


: 2016-11-18; !; : 542 |


:

:

, .
==> ...

1426 - | 1231 -


© 2015-2024 lektsii.org - -

: 0.128 .