Листинги программ к лабораторной работе 2

uses

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

Dialogs, StdCtrls, Buttons;

type

TForm1 = class(TForm)

ListBox1: TListBox;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

BitBtn1: TBitBtn;

Button1: TButton;

procedure BitBtn1Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure ListBox1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);

begin

close;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

case listBox1.ItemIndex of

0: Label3.Caption:= 'черный ОООООО';

1: Label3.Caption:=' белый FFFFFF';

2: Label3.Caption:=' красный FFOOOO';

3: Label3.Caption:=' зеленый OOFFOO';

4: Label3.Caption:= 'бирюзовый OOFFFF';

5: Label3.Caption:=' синий OOOOFF';

6: Label3.Caption:=' фиолетовый FFOOFF';

7: Label3.Caption:= ' желтый FFFFOO';

8: Label3.Caption:= 'коричневый 996633';

9: Label3.Caption:= ' оранжевый FF8000';

10: Label3.Caption:= ' липовый 8000FF';

11: Label3.Caption:=' серый АОАОАО';

end;

end;

end.

unit Unit1;

interface

uses

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

Dialogs, StdCtrls;

type

TForm1 = class(TForm)

ComboBox1: TComboBox;

ComboBox2: TComboBox;

Button1: TButton;

Button2: TButton;

Button3: TButton;

procedure FormCreate(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

procedure Button3Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1; i, max, min, maxi,mini:integer;

a:array[1..10] of integer;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);

begin

i:=0;

comboBox1.Clear;

combobox2.Clear;

combobox1.TabOrder:=0;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

combobox1.items.add(combobox1.Text);

i:=i+1;

a[i]:=strtoint(combobox1.Text);

combobox1.SetFocus;

end;

procedure TForm1.Button2Click(Sender: TObject);

var k:integer;

begin

max:=a[1]; maxi:=1; min:=a[1]; mini:=1;

for k:=2 to 10 do

begin

if max<a[k] then

begin

max:=a[k];

maxi:=i;

end;

if min>a[k] then

begin

min:=a[k];

mini:=i;

end;

end;

a[maxi]:=min;

a[mini]:=max;

for k:=1 to 10 do

combobox2.Items.Add(inttostr(a[k]));

combobox2.DroppedDown:=true;

end;

procedure TForm1.ComboBox1KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

begin

if key=13 then button1.SetFocus;

end;

procedure TForm1.Button3Click(Sender: TObject);

begin

close;

end;

end.

Приложение В


Понравилась статья? Добавь ее в закладку (CTRL+D) и не забудь поделиться с друзьями:  



double arrow
Сейчас читают про: