unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Label1: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Label2: TLabel;
Edit3: TEdit;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
end;
Tinf=record
k:integer;
{ a:array[1..10]of byte;}
end;
psel=^sel;
sel=record
inf:Tinf;
A:psel;
end;
TList=class(tObject)
sp1,sp:psel;
constructor Create;
procedure Addl(inf:Tinf);
procedure Print;
procedure Podschet;
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
stec:TList;
inf:Tinf;
max,n,m,i,j:integer;
s:string;
a:array[1..10]of byte;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
for j:=1 to 10 do begin
a[j]:=0;
end;
listbox1.Clear;
m:=strtoint(edit3.Text);
stec.Free;
randomize;
stec:=TList.Create;
for i:=1 to m do begin
inf.k:=(random(10)+1);
stec.Addl(inf);
listbox1.Items.Add(inttostr(inf.k));
end;
stec.Print;
stec.Podschet;
edit1.text:=inttostr(n);
edit2.text:=inttostr(max);

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
listbox1.Clear;
m:=strtoint(edit3.text);
edit1.text:='';
edit2.Text:='';

end;

constructor TList.Create;
begin
Inherited Create;
sp1:=nil;
end;

procedure TList.Addl(inf:Tinf);
begin
if sp1=nil then begin
new(sp1);
sp1^.A:=nil;
sp1^.inf:=inf;
end
else begin
new(sp);
sp^.A:=sp1;
sp^.inf:=inf;
sp1:=sp;
end;
end;

Procedure Tlist.Print;
begin
sp:=sp1;
While sp<>Nil do begin
for j:=1 to 10 do begin
if sp^.inf.k=j then begin
a[j]:=a[j]+1;
end
end;
sp:=sp^.A;
end;

end;

procedure Tlist.Podschet;
begin
n:=0;
sp:=sp1;
max:=0;
While sp<>Nil do begin
for j:=1 to 10 do begin
if max<=a[j]then begin
max:=a[j];
n:=j;
end;
end;
sp:=sp^.A;
end;

{sp:=sp1;
s:=inttostr(n);

While sp<>Nil do begin
for j:=1 to 10 do begin
if max=a[j]then begin
s:=s+', '+inttostr(j);
end;
end;
sp:=sp^.A;
end;}

end;


end.
Соседние файлы в папке наиб.часто встреч.число+сколько раз
  • #
    15.06.20146.6 Кб10Unit1.dcu
  • #
    15.06.20141.82 Кб10Unit1.dfm
  • #
    15.06.20142.5 Кб10Unit1.pas
  • #
    15.06.20141.83 Кб10Unit1.~dfm
  • #
    15.06.20142.04 Кб10Unit2.dcu
  • #
    15.06.20141.21 Кб10Unit2.pas
  • #
    15.06.20141.13 Кб10Unit2.~pas