.


:




:

































 

 

 

 


қ ұ 8




ө өң . ListBox .

 

(10) ә , ң .

.

1.ң ғ D:\My Project\LBOX құ.

2. File/New/Application қ ң .

 

3. Standard Form1 ғ ң. : Edit, Button, ListBox.

 


4. қ Edit1 Text қ қ. ғ Captionқ ң ә : , ң ғ - .

5. Interfaceө қ ә ө ө:

A: array [110] of integer;

I, min, max, Imax, imin: integer;

6. Form1 , On Create қғ ғ құ: I: =0

ListBox1. Clear ListBox2. Clear;

 

7. қ ә On Click қғ ң:

ListBox1. Items. Add (Edit. Text); I: =I+1;

A [I]: =StrToInt (Edit. Text); Edit1. Set Focus

8. қ -қғ ұ ә :

max:=a[1];

imax:=1;

min:=a[1];

imin:=1;

for k:=2 to 10 do begin

if max<a[k] then begin max:=a[k]; imax:=k

end;

if min>a[k] then begin min:=a[k]; imin:=k

end;

end;

a[imax]:=min;

a[imin]:=max; for k:=1 to 10 do

ListBox2.Items.Add(IntToStr(a[k]));

 

9. Edit 1 ң ү OnKeyDown қғ қ құ ұ өң құ.Enter қ ң ө:

 

If key=13 then Button1. Set Focus

10. File/Save All ққ.

11. F9 қ ғ . қ ң ғ Enter- . ң ө ұ. қ қ ә .

 


 

 

ң қң қ ө. unit LBox;

 

interface

 

uses

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

 

type

TForm1 = class(TForm) ListBox1: TListBox; ListBox2: TListBox; Button1: TButton; Button2: TButton;

procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: Tobject); procedure Button2Click(Sender: TObject);

procedure Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure Edit1Change(Sender: TObject);

private

{ Private declarations } public

{ Public declarations } end;

 

var

Form1: TForm1; a:array[1..10] of integer; i,min,max,imax,imin:integer;

 

implementation

 

{$R *.DFM}

 


procedure TForm1.Button1Click(Sender: TObject); begin

ListBox1.Items.Add(Edit1.Text); i:=i+1; a[i]:=StrToInt(Edit1.Text); Edit1.SetFocus

end;

 

procedure TForm1.FormCreate(Sender: TObject); begin

i:=0;

ListBox1.Clear

ListBox2.Clear;

end;

 

procedure TForm1.Button2Click(Sender: TObject); var k:integer;

begin max:=a[1]; imax:=1; min:=a[1]; imin:=1;

for k:=2 to 10 do begin

if max<a[k] then begin max:=a[k]; imax:=k

end;

if min>a[k] then begin min:=a[k]; imin:=k

end;

end;

a[imax]:=min;

a[imin]:=max; for k:=1 to 10 do

ListBox2.Items.Add(IntToStr(a[k]));

end;

 

procedure TForm1.Edit1KeyDown(Sender: Tobject:var Key: Word; Shift:TShiftstate);

begin

If key = 13 then Button1.SetFocus end;

 

procedure TForm1.Edit1Change(Sender: TObject); begin

if key = 13 then Button1.SetFocus end;

 


end.

 





:


: 2017-01-28; !; : 547 |


:

:

.
==> ...

1507 - | 1431 -


© 2015-2024 lektsii.org - -

: 0.013 .