llirik

Untitled

Dec 8th, 2020
1,501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.55 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Memo1: TMemo;
  12.     Memo2: TMemo;
  13.     Button1: TButton;
  14.     Button2: TButton;
  15.     procedure Button1Click(Sender: TObject);
  16.     procedure Button2Click(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.     mas: array of string; // глобальная переменная
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27. implementation
  28.  
  29. {$R *.dfm}
  30.  
  31. procedure TForm1.Button1Click(Sender: TObject);
  32. var
  33.   i, c_strings:integer;  // c_strings - кол-во строк в Memo1
  34.  
  35. begin
  36.   c_strings := Memo1.Lines.Count;
  37.  
  38.   SetLength(mas, c_strings);  // устанавливаем размеры массива mas
  39.   for i:=0 to c_strings do
  40.     mas[i] := Memo1.Lines[i]; // заполняем массив
  41.  
  42. end;
  43.  
  44. procedure TForm1.Button2Click(Sender: TObject);
  45. var
  46.   i,j,c:integer;
  47.   mas2: array of string;
  48.   c_mas: array of integer;
  49. begin
  50.   Memo2.Lines.clear; // очистка Memo2
  51.   SetLength(mas2, Length(mas));
  52.   SetLength(c_mas, Length(mas));
  53.  
  54.   for i:=0 to Length(mas) do
  55.     c_mas[i] := 1;
  56.  
  57.  
  58.   for i:=0 to Length(mas) do
  59.     for j:=0 to Length(mas) do
  60.       if (mas[i] = mas[j]) and (i <> j) then
  61.         c_mas[i] := c_mas[i] + 1;
  62.  
  63.   c := 0;
  64.   for i:=0 to Length(mas) do
  65.     if c_mas[i] = 1 then begin
  66.       mas2[c] := mas[i];
  67.       c := c + 1;
  68.     end;
  69.  
  70.   for i:=0 to Length(mas2) do
  71.     Memo2.Lines.Add(mas2[i]);
  72.  
  73. end;
  74.  
  75. end.
  76.  
Advertisement
Add Comment
Please, Sign In to add comment