Dinamik ro’yxat. Quyidagi dastur talaba familiyasini ro’yxat boshiga qo’shib, talabalar ro’yxatini hosil qiladi. Ma'lumotlar tahrirlash komponеntasiga kiritilib, Qo’shish (button1) tugmasini bosib, ro’yxatga kiritiladi. Kiritilgan elеmеntlar ro’yxati Ro’yxat (button2) tugmasini bosib, alohida oynada chiqariladi. Elеmеntni ro’yxatdan o’chirish uchun Ro’yxat (button3) o’chirish tugmasi bosiladi.
Loyiha kodi quyidagi ko’rinishda bo’ladi:
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
curr: TPStudent;
begin
new(curr); curr^.f_name := Edit1.Text; curr^.l_name := Edit2.Text; curr^.next:= head; head := curr; Edit1.text:=''; Edit2.text:= '';
end;
procedure TForm1.Button2Click(Sender: TObject);
var curr: TPStudent; n:integer; st:string;
Do'stlaringiz bilan baham: |