0% found this document useful (0 votes)
56 views3 pages

Diana Cernetchi 11C Pascal

The document defines data structures and procedures to manage a linked list of student records. It defines a record to store a student's name and grade, and uses pointers to link records together in a list. Procedures are defined to create the list by inputting data, display the list, and select records where the name starts with C. The main program section calls the defined procedures to test the list implementation.

Uploaded by

Sandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views3 pages

Diana Cernetchi 11C Pascal

The document defines data structures and procedures to manage a linked list of student records. It defines a record to store a student's name and grade, and uses pointers to link records together in a list. Procedures are defined to create the list by inputting data, display the list, and select records where the name starts with C. The main program section calls the defined procedures to test the list implementation.

Uploaded by

Sandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

//Ex.

4b last1 := p1;
end;
type p1 := first1;
sved = ^anketa; while p1 <> nil do
anketa = record begin
fio: string; writeln(p1^.fio:15, p1^.voz:10);
voz: byte; p1 := p1^.next;
next: sved; end;
end; writeln('Listei 1 se vor atasa
elementele listei 2 - 1');
var writeln('Listei 2 se vor atasa
first, first1: sved; elementele listei 1 - 2');
last, last1: sved; repeat
p, p1: sved; write('Introdu 1 sau 2:
n, i: byte; ');readln(i);
until i in [1, 2];
begin case i of
write('Nr elementelor in 1:
lista:');readln(n); begin
new(first); last^.Next := First1;
write('Introduceti numele si last := last1;
prenumele:'); p1 := first;
readln(first^.fio); while p1 <> nil do
write('Introduceti varsta:'); begin
readln(first^.voz); writeln(p1^.fio:15,
first^.next := nil; p1^.voz:10);
last := first; p1 := p1^.next;
for i := 2 to n do end;
begin end;
new(p); 2:
write('Introduceti numele si begin
prenumele:'); last1^.Next := First;
readln(p^.fio); last1 := last;
write('Introduceti varsta:'); p1 := first1;
readln(p^.voz); while p1 <> nil do
p^.next := nil; begin
last^.next := p; writeln(p1^.fio:15,
last := p; p1^.voz:10);
end; p1 := p1^.next;
p := first; end;
while p <> nil do end;
begin end;
writeln(p^.fio:15, p^.voz:10); readln;
p := p^.next; end.
end;
readln;

write('Nr elementelor in
lista:');readln(n);
new(first1);
write('Introduceti numele si
prenumele:');
readln(first1^.fio);
write('Introduceti varsta:');
readln(first1^.voz);
first1^.next := nil;
last1 := first1;
for i := 2 to n do
begin
new(p1);
write('Introduceti numele si
prenumele:');
readln(p1^.fio);
write('Introduceti varsta:');
readln(p1^.voz);
p1^.next := nil;
last1^.next := p1;
//Ex.3 c:=p;
while c<>nil do
type begin
ac = ^candidat; if c^.np=cheie then goto 1;
candidat = record c:=c^.urm;
np: string; end;
nm: real; 1:if c=nil then begin
urm: ac; writeln('Element inexistent');
end; dispose(q);
var p,c,u,g:ac; end
else begin
procedure creare; q^.urm:=c^.urm;
var c,u:ac; s:string; c^.urm:=q;
begin end;
writeln('Dati lista de elevi si nota lor end;
medie: (Pentru a finisa lista itroduceti
"end")');readln(s); procedure afis7_5;
while s<>'end' do begin
begin writeln('Persoanele cu media mai mare
new(c); c^.np:=s; readln(c^.nm); ca 7,5');
c^.urm:=nil; c:=p;
if p=nil then p:=c else u^.urm:=c;u:=c; while c<>nil do
readln(s); begin
end; if c^.nm>=7.5 then
end; writeln(c^.np,':',c^.nm);
c:=c^.urm;
procedure afisare; end;
begin end;
writeln('Lista curenta este:');
c:=p; procedure listanoua;
while c<>nil do var q:ac;
begin begin
writeln(c^.np,':',c^.nm); g:=nil;c:=p;
c:=c^.urm; while c<>nil do begin
end; if c^.nm>=9.0 then begin
end; new(q); q^.np:=c^.np;
q^.nm:=c^.nm; q^.urm:=nil;
procedure exclude; if g=nil then begin
label 1; g:=q; u:=q; end
var q:ac; cheie: string; else begin
begin u^.urm:=q; u:=q; end;
writeln('Introduceti numele elveului ce end;
urmeaza sa fie exclus'); c:=c^.urm;
readln(cheie); end;
c:=p;q:=c; end;
while c<>nil do begin
if c^.np=cheie then goto 1; procedure exclud6;
q:=c; c:=c^.urm; var q:ac;
end; begin
1: if c=nil then writeln('Element writeln('Se exclud persoanele cu media
inexistent') mai mica ca 6.0');
else begin if c=p then p:=c^.urm c:=p;q:=c;
else q^.urm:=c^.urm; while c<>nil do begin
dispose(c); if c^.nm<6 then
end; if c=p then begin p:=c^.urm; u:=p;
end; dispose(c);c:=u; end
else begin u^.urm:=c^.urm;
procedure includ; dispose(c);c:=u^.urm; end
label 1; else begin u:=c; c:=c^.urm; end;
var q:ac; cheie: string; end;
begin end;
new(q);writeln('Dati datele elevului ce
urmeaza sa fie inclus');
readln(q^.np);readln(q^.nm); begin
writeln('Indicati dupa ce persoana se creare;
face includerea'); exclude;afisare;
readln(cheie); includ;afisare;
afis7_5; creare; afisare; select;
listanoua; end.
exclud6;afisare;
end.

program Ex_4d;

type
AdresaCandidat = ^Candidat;
Candidat = record
NumePrenume: string;
NotaMedie: real;
Urm: AdresaCandidat;
end;

var
p, c, u, p1: AdresaCandidat;
n: integer;

procedure creare;
var
i: integer;
begin
write('n=');readln(n);
new(c);
readln(c^.NumePrenume);
readln(c^.NotaMedie);
c^.Urm := nil;
p := c;u := c;
for i := 2 to n do
begin
new(c);
readln(c^.NumePrenume);
readln(c^.NotaMedie);
c^.Urm := nil;
u^.Urm := c;
u := c;
end;
end;

procedure afisare;
begin
c := p;
while c <> nil do
begin
writeln(c^.NumePrenume);
writeln(c^.NotaMedie);
c := c^.Urm;
end;
end;

procedure select;
begin
c:=p;
writeln('Elevii ai caror nume incepe cu
C:');
while c<>nil do begin
if c^.NumePrenume [1]='C' then
writeln(c^.NumePrenume);
c:=c^.urm;
end;
end;

begin

You might also like