Урок на делфи. 85 Количество повторений цифр в файле
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
AnimateWindow (handle, 5000, AW_BLEND);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Label1.Caption:=IntToStr(Screen.Width);
Label2.Caption:=IntToStr(Screen.Height);
Form1.Left:= (Screen.Width - Form1.Width) div 2;
Form1.Top:= (Screen.Height - Form1.Height) div 2;
AnimateWindow (handle, 5000, AW_BLEND );
end;
end.
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
bd:TStringList;
i,j,c:integer;
s:string;
metka:Boolean;
begin
Memo1.ScrollBars:=ssVertical;
Memo1.Clear;
bd:=TStringList.Create;
bd.LoadFromFile('..\..\bd.txt');
metka:=false;
Label1.Caption:='- '+IntToStr(bd.Count);
c:=0;
for I := 0 to bd.Count-1 do
begin
s:=bd[i];
for j := 0 to bd.Count-1 do
begin
if s=bd[j] then
c:=c+1;
end;
for j := 0 to Memo1.Lines.Count-1 do
begin
if pos (s+' = ',Memo1.Lines[j])>0 then
metka:=true;
end;
if (metka=false) then
Memo1.Lines.Add(s+' = '+IntToStr(c)) ;
c:=0;
metka:=false;
end;
Label2.Caption:='- '+IntToStr(Memo1.Lines.Count);
FreeAndNil(bd);
end;
end.