linkedin facebook linkedin facebook nod32

Tartiblangan ro`yxat

Muallif: Mengliyev SH.

Qo`shilgan sana: 2014-09-16

Tartiblangan ro‘yxat

      Odatda ro‘yxatlar tartiblangan bo‘ladi. Misol uchun talabalar ruyxati familiya bo‘yicha tartiblangan bo‘ladi.
Elementni tartiblangan ro‘yxatga qo‘shish uchun avval shu elementdan oldin turishi kerak bo‘lgan element topiladi. SHundan so‘ng ko‘rsatkichlar qiymatlari o‘zgartiriladi.

Quyidagi dastur Familiya maydoni bo‘yicha tartiblangan ro‘yxat hosil qiladi. Dastur formasi ishlash jarayoni rasmda ko‘rsatilgan.

Dastur matni

unit Unit3;

interface

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

type
  TForm1 = class(TForm)
    Label2: TLabel;
    Edit1: TEdit;
    Label3: TLabel;
    Edit2: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
   procedure FormActivate(Sender: TObject);
   private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
{$R *.DFM}
type
TPStudent=^TStudent;
TStudent = record
f_name:string[20];
l_name: string[20];
next: TPStudent;
end;
var
head: TPStudent;
procedure TForm1.Button1Click(Sender: TObject);
var
node: TPStudent;
curr: TPStudent;
pre: TPStudent;
begin
new(node);
node^.f_name:=Edit1.Text;
node^.l_name:=Edit2.Text;
curr:=head;
pre:=NIL;
while (curr<>NIL) and (node.f_name > curr^.f_name) do
begin
pre:= curr;
curr:=curr^.next;
end;
if pre = NIL then
begin
node^.next:=head; head:=node;
end
else
begin
node^.next:=pre^.next;
pre^.next:=node;
end;
Edit1.text:='';
Edit2.text:='';
Edit1.SetFocus;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
curr: TPStudent;
n:integer;
st:string;
begin n := 0; st := '';
curr := head;
while curr <> NIL do begin
n := n + 1;
st := st + curr^.f_name + ' ' + curr^.l_name+#13;
curr := curr^.next;
    end;
if n <> 0
then ShowMessage('Ñïèñîê:' + #13 + st)
else ShowMessage('Â ñïèñêå íåò ýëåìåíòîâ.');

end;
 procedure TForm1.Button3Click(Sender: TObject);
var
curr: TPStudent;
begin
if head<>NIL then

 if head^.next=NIL then
 begin
 Dispose(head);
 head:=NIL;
 end
 else
 begin
 new(curr);
 curr:=head;
 head:=curr^.next;
 Dispose(curr);
 end;
end;
  procedure TForm1.FormActivate(Sender: TObject);
begin
head:=NIL;
end;
end.

1581 marta o`qildi.

Parol:
Eslab qolish.


Ro`yhatdan o`tish

testing

+998915878681

Siz o`z maxsulotingizni 3D reklama ko`rinishda bo`lishini xohlaysizmi? Unda xamkorlik qilamiz.

3D Reklama


Рейтинг@Mail.ru
Рейтинг@Mail.ru

Besucherzahler
счетчик посещений