Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, unit2, Vcl.StdCtrls;
- type
- TForm1 = class(TForm)
- Button1: TButton;
- ListBox1: TListBox;
- ListBox2: TListBox;
- Label1: TLabel;
- Label2: TLabel;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- a, b: list;
- implementation
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- var
- i, n: integer;
- begin
- n := StrToInt(InputBox('Input n', 'n = ' , '')); // Вводим количество товаров
- SetLength(a, n); //Выделяем память под массив
- for i := 0 to n - 1 do //вводим все товары
- begin
- a[i].name := InputBox('Input name', 'name = ' , '');
- a[i].country := InputBox('Input country', 'country = ' , '');
- a[i].count := StrToInt(InputBox('Input count', 'count = ' , ''));
- a[i].price := StrToFloat(InputBox('Input price', 'price = ' , ''));
- end;
- ListBox1.Clear; //очищаем листбокс(на всякий случай)
- for i := 0 to n - 1 do // Выводим массив в листбокс
- ListBox1.Items.Add(a[i].name + ' ' + a[i].country + ' ' + IntToStr(a[i].count) + ' ' + FloatToStr(a[i].price));
- Label1.Caption := 'Стоимость всех товаров = ' + FloatToStr(countfullprice(a));
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- var
- i: integer;
- begin
- ListBox1.Clear; // очищаем листбокс
- sortlist(a); //сортируем массив
- for i := 0 to High(a) do //выводим массив
- ListBox1.Items.Add(a[i].name + ' ' + a[i].country + ' ' + IntToStr(a[i].count) + ' ' + FloatToStr(a[i].price));
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- var
- sname: string;
- i: integer;
- begin
- ListBox2.Clear; //очищаем листбокс
- sname := InputBox('Specify name', 'sname = ', ''); //вводим интересующее нас имя товара
- createspecialarr(a, sname, b); //создаем массив товаров с такими именами
- for i := 0 to High(b) do // выводим его в листбокс
- ListBox2.Items.Add(b[i].name + ' ' + b[i].country + ' ' + IntToStr(b[i].count) + ' ' + FloatToStr(b[i].price))
- end;
- procedure TForm1.Button4Click(Sender: TObject);
- var
- scountry: string;
- begin
- scountry := InputBox('Specify country', 'scountry = ', ''); // вводим интересующую нас страну
- Label2.Caption := 'Количество товаров из страны ' + scountry + ' = ' + IntToStr(countsitems(a, scountry)); //считаем товары из нее
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement