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, StdCtrls;
- type
- TForm1 = class(TForm)
- Memo1: TMemo;
- Memo2: TMemo;
- Button1: TButton;
- Button2: TButton;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- mas: array of string; // глобальная переменная
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- var
- i, c_strings:integer; // c_strings - кол-во строк в Memo1
- begin
- c_strings := Memo1.Lines.Count;
- SetLength(mas, c_strings); // устанавливаем размеры массива mas
- for i:=0 to c_strings do
- mas[i] := Memo1.Lines[i]; // заполняем массив
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- var
- i,j,c:integer;
- mas2: array of string;
- c_mas: array of integer;
- begin
- Memo2.Lines.clear; // очистка Memo2
- SetLength(mas2, Length(mas));
- SetLength(c_mas, Length(mas));
- for i:=0 to Length(mas) do
- c_mas[i] := 1;
- for i:=0 to Length(mas) do
- for j:=0 to Length(mas) do
- if (mas[i] = mas[j]) and (i <> j) then
- c_mas[i] := c_mas[i] + 1;
- c := 0;
- for i:=0 to Length(mas) do
- if c_mas[i] = 1 then begin
- mas2[c] := mas[i];
- c := c + 1;
- end;
- for i:=0 to Length(mas2) do
- Memo2.Lines.Add(mas2[i]);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment