sâmbătă, 28 mai 2011

Probleme informatica - examen titularizare

Am gasit pe internet cateva probleme pentru examenul de titularizare. Sunt problepe pentru alocarea dinamica, liste, stive si coada. Nu prea inteleg eu termenii astia dar care se pregateste pentru informatica sunt sigura ca ii cunoaste :)

program lista_dubla;
uses wincrt;
type ref=^inr;
inr=record
nr:integer;
adr:ref;
ad,as:ref;
end;
var b,s,c:ref;
i,m,n:integer;
procedure creare(var b,s:ref);
begin
write('n=');readln(n);
new(b);
b^.nr:=n;
b^.as:=nil;
b^.ad:=nil;
s:=b;
end;
procedure adauga(var sf:ref);
var d:ref;
begin
write('n=');readln(n);
new(d);d^.nr:=n;
d^.as:=s;
d^.ad:=nil;
s^.ad:=d;
s:=d;
end;

procedure afisare(b:ref);
var d:ref;
begin
d:=b;
while d<>nil do begin
writeln(d^.nr,' ');
d:=d^.ad;
end;
end;

procedure inclus(m:integer;b:ref);
var d,e:ref;
begin
d:=b;
while d^.nr<>m do
d:=d^.ad;
write('n=');readln(n);
new(e);
e^.nr:=n;
e^.as:=d;
d^.ad^.as:=e;
e^.ad:=d^.ad;
d^.ad:=e;
end;

procedure sterge(m:integer;b:ref);
var d:ref;
begin
d:=b;
while d^.nr<>m do
d:=d^.ad;
d^.as^.ad:=d^.ad;
d^.ad^.as:=d^.as;
dispose(d);
end;

begin
creare(b,s);
write('m=');readln(m);
for i:=1 to m do
adauga(s);
afisare(b);
write('m=');readln(m);
inclus(m, b);afisare(b);
write('m=');readln(m);
sterge(m, b);afisare(b);
end.


program lista_liniara_simpla;
uses wincrt;
type adresa=^nod;
nod=record
nr:integer;
adr:adresa;
end;
var p,u:adresa;
i:integer;
procedure adaug(var p,u:adresa;val:integer);
var c:adresa;
begin
if p=nil then begin
new(p);
p^.nr:=val;
p^.adr:=nil;
u:=p;
end
else begin
new©;
u^.adr:=c;
c^.nr:=val;
c^.adr:=nil;
u:=c;
end;
end;

procedure inserare_dupa(p:adresa;var u:adresa;val,val1:integer);
var c,d:adresa;
begin
c:=p;
while c^.nr<>val do
c:=c^.adr;
new(d);
d^.nr:=val1;
d^.adr:=c^.adr;
c^.adr:=d;
if d^.adr=nil then u:=d;
end;

procedure inserare_inainte(var p:adresa;val,val1:integer);
var c,d:adresa;
begin
if p^.nr= val then begin
new(d);
d^.nr:=val1;
d^.adr:=p;
p:=d;
end
else begin
c:=p;
while c^.adr^.nr<>val do
c:=c^.adr;
new(d);
d^.nr:=val1;
d^.adr:=c^.adr;
c^.adr:=d;
end;
end;

procedure sterg(var p,u:adresa;val:integer);
var c,aux:adresa;
begin
if p^.nr=val then begin
aux:=p;
p:=p^.adr;
end
else begin
c:=p;
while c^.adr^.nr<>val do
c:=c^.adr;
aux:=c^.adr;
c^.adr:=aux^.adr;
if aux=u then
u:=c; end;
dispose(aux);
end;

procedure afisare(p:adresa);
var c:adresa;
begin
c:=p;
while c<> nil do begin
write(c^.nr,' ');
c:=c^.adr;
end;
writeln;
end;

begin

for i:=1 to 15 do
adaug(p,u,i);
afisare(p);
inserare_dupa(p,u,2,32);
afisare(p);
inserare_inainte(p,6,18);
sterg(p,u,1);
sterg(p,u,7);
afisare(p);
end.

Alte probleme rezolvate pentru titularizare informatica gasiti
Subiecte rezolvate - titularizare informatica


Bacalaureat, Titularizare si Suplinire

Niciun comentariu:

Trimiteți un comentariu

Aici poti comenta articolul, poti cere informatii sau poti oferi chiar tu altora informatii utile...
Semnatura nu e obligatorie, dar va rog semnati-va.

SEO Romania Certificat Web