Advertisement
Kentoo

Untitled

Jun 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 2.97 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.  Dialogs, unit2, Vcl.StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     ListBox1: TListBox;
  13.     ListBox2: TListBox;
  14.     Label1: TLabel;
  15.     Label2: TLabel;
  16.     Button2: TButton;
  17.     Button3: TButton;
  18.     Button4: TButton;
  19.     procedure Button1Click(Sender: TObject);
  20.     procedure Button2Click(Sender: TObject);
  21.     procedure Button3Click(Sender: TObject);
  22.     procedure Button4Click(Sender: TObject);
  23.   private
  24.     { Private declarations }
  25.   public
  26.     { Public declarations }
  27.   end;
  28.  
  29. var
  30.   Form1: TForm1;
  31.   a, b: list;
  32.  
  33. implementation
  34.  
  35. {$R *.dfm}
  36.  
  37. procedure TForm1.Button1Click(Sender: TObject);
  38. var
  39.   i, n: integer;
  40. begin
  41.   n := StrToInt(InputBox('Input n', 'n = ' , '')); // Вводим количество товаров
  42.   SetLength(a, n); //Выделяем память под массив
  43.   for i := 0 to n - 1 do //вводим все товары
  44.     begin
  45.       a[i].name := InputBox('Input name', 'name = ' , '');
  46.       a[i].country := InputBox('Input country', 'country = ' , '');
  47.       a[i].count := StrToInt(InputBox('Input count', 'count = ' , ''));
  48.       a[i].price := StrToFloat(InputBox('Input price', 'price = ' , ''));
  49.     end;
  50.   ListBox1.Clear; //очищаем листбокс(на всякий случай)
  51.   for i := 0 to n - 1 do // Выводим массив в листбокс
  52.     ListBox1.Items.Add(a[i].name + ' ' + a[i].country + ' ' + IntToStr(a[i].count) + ' ' + FloatToStr(a[i].price));
  53.   Label1.Caption := 'Стоимость всех товаров = ' + FloatToStr(countfullprice(a));
  54. end;
  55.  
  56. procedure TForm1.Button2Click(Sender: TObject);
  57. var
  58.   i: integer;
  59. begin
  60.   ListBox1.Clear; // очищаем листбокс
  61.   sortlist(a); //сортируем массив
  62.   for i := 0 to High(a) do //выводим массив
  63.     ListBox1.Items.Add(a[i].name + ' ' + a[i].country + ' ' + IntToStr(a[i].count) + ' ' + FloatToStr(a[i].price));
  64. end;
  65.  
  66. procedure TForm1.Button3Click(Sender: TObject);
  67. var
  68.   sname: string;
  69.   i: integer;
  70. begin
  71.   ListBox2.Clear; //очищаем листбокс
  72.   sname := InputBox('Specify name', 'sname = ', ''); //вводим интересующее нас имя товара
  73.   createspecialarr(a, sname, b); //создаем массив товаров с такими именами
  74.   for i := 0 to High(b) do // выводим его в листбокс
  75.     ListBox2.Items.Add(b[i].name + ' ' + b[i].country + ' ' + IntToStr(b[i].count) + ' ' + FloatToStr(b[i].price))
  76. end;
  77.  
  78. procedure TForm1.Button4Click(Sender: TObject);
  79. var
  80.   scountry: string;
  81. begin
  82.   scountry := InputBox('Specify country', 'scountry = ', ''); // вводим интересующую нас страну
  83.   Label2.Caption := 'Количество товаров из страны ' + scountry + ' = ' + IntToStr(countsitems(a, scountry)); //считаем товары из нее
  84. end;
  85.  
  86. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement