P. 1
tema9

tema9

|Views: 0|Likes:
Published by Adrian Pãtulea

More info:

Published by: Adrian Pãtulea on Apr 20, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

04/20/2013

pdf

text

original

program carti;

type carte=record
autor:array[1..5] of string[50];
titlu:string[50];
editura:string[50];
an:integer;
na:integer;
end;
var a:array[1..50] of carte;
b:array[1..50] of carte;
aux:carte;
lista_autori:array[1..50] of string[50];
edituri:array[1..50] of string[50];
nr_titluri:array[1..50] of integer;
n,i,j,k,l,ok,auxi:integer;
nume_autor,auxs:string[50];
an_init:integer;
an_fin:integer;
g:text;
{*************************************************************}
{*************************************************************}
begin
assign(g, 'iesire.txt');
rewrite(g);
write('Numarul cartilor este:');
readln(n);
for i:=1 to n do
begin
writeln('Introduceti date pentru cartea cu numarul ',i);
write('Titlu:');
readln(a[i].titlu);
write('Editura:');
readln(a[i].editura);
write('An aparitie:');
readln(a[i].an);
write('Numar autori:');
readln(a[i].na);
for j:=1 to a[i].na do
begin
write('Autor ',j,':');
readln(a[i].autor[j]);
end;
end;
writeln;
if (n>0) then
begin
write('Introduceti numele unui autor:');
readln(nume_autor);
writeln('Introduceti o perioada de timp.');
write('An initial:');
readln(an_init);
write('An final:');
readln(an_fin);
end;
writeln;
writeln(g,'1. Lista cartilor in ordinea introducerii este:');
for i:=1 to n do
begin
writeln(g,'Titlu:',a[i].titlu);
writeln(g,'Editura:',a[i].editura);
writeln(g,'An aparitie:',a[i].an);
write(g,'Autori: ');
for j:=1 to a[i].na do
write(g,a[i].autor[j],', ');
writeln(g);
writeln(g);
end;
writeln(g);
{*************************************************************}
k:=0;
for i:=1 to n do
for j:=1 to a[i].na do
begin
ok:=0;
for l:=1 to k do
if (a[i].autor[j]=lista_autori[l]) then
begin
nr_titluri[l]:=nr_titluri[l]+1;
ok:=1;
end;
if (ok=0) then
begin
k:=k+1;
lista_autori[k]:=a[i].autor[j];
nr_titluri[k]:=1;
end;
end;
for i:=1 to k-1 do
for j:=i+1 to k do
if (ord(lista_autori[i][1])>ord(lista_autori[j][1])) then
begin
auxs:=lista_autori[i];
lista_autori[i]:=lista_autori[j];
lista_autori[j]:=auxs;
auxi:=nr_titluri[i];
nr_titluri[i]:=nr_titluri[j];
nr_titluri[j]:=auxi;
end;
writeln(g,'2. Lista autorilor ordonati alfabetic, si numarul de titluri este:');
for i:=1 to k do
begin
write(g,lista_autori[i]);
writeln(g,', ', nr_titluri[i], ' titluri');
end;
writeln(g);
{*************************************************************}
k:=0;
for i:=1 to n do
begin
ok:=1;
for j:=1 to k do
if (a[i].editura=edituri[j]) then
ok:=0;
if (ok=1) then
begin
k:=k+1;
edituri[k]:=a[i].editura;
end;
end;
for i:=1 to k-1 do
for j:=i+1 to k do
if (a[i].an>a[j].an) then
begin
aux:=a[i];
a[i]:=a[j];
a[j]:=aux;
end;
writeln(g,'3. Lista titlurilor grupate pe edituri ordonate cronologic este:');
for i:=1 to k do
begin
writeln(g,'Editura: ',edituri[i]);
for j:=1 to n do
if (a[j].editura=edituri[i]) then
begin
write(g,a[j].titlu, ' Autori: ');
for l:=1 to a[j].na do
write(g,a[j].autor[l],', ');
writeln(g);
writeln(g);
end;
end;
{*************************************************************}
writeln(g,'4. Lista titlurilor pentru ',nume_autor,' ordonata cronologic este:'
);
for i:=1 to n do
for j:=1 to a[i].na do
if (nume_autor=a[i].autor[j]) then
writeln(g,a[i].titlu);
writeln(g);
{*************************************************************}
for i:=1 to k-1 do
for j:=i+1 to k do
if (ord(a[i].titlu[1])>ord(a[j].titlu[1])) then
begin
aux:=a[i];
a[i]:=a[j];
a[j]:=aux;
end;
writeln(g,'5. Lista titlurilor aparute intre ',an_init,' si ',an_fin,' este:');
for i:=1 to n do
if ((a[i].an>=an_init) and (a[i].an<=an_fin)) then
begin
writeln(g,'Titlu:',a[i].titlu);
writeln(g,'Editura:',a[i].editura);
writeln(g,'An aparitie:',a[i].an);
write(g,'Autori: ');
for j:=1 to a[i].na do
write(g,a[i].autor[j],', ');
writeln(g);
writeln(g);
end;
close(g);
end.

writeln(g.writeln(g. end.'An aparitie:'. '). lista_autori[k]:=a[i]. ' titluri').an).'Autori: '). for i:=1 to n do for j:=1 to a[i]. end. lista_autori[i]:=lista_autori[j]. end. writeln(g).editura=edituri[j]) then ok:=0. nr_titluri[i]. auxi:=nr_titluri[i]. writeln(g). writeln(g).'. if (ok=1) then begin k:=k+1.na do write(g. lista_autori[j]:=auxs. for i:=1 to k do begin write(g. end.autor[j].'. for i:=1 to n do begin ok:=1. end.autor[j]. {*************************************************************} k:=0.a[i]. .editura. for l:=1 to k do if (a[i]. for j:=1 to a[i]. end. nr_titluri[j]:=auxi. writeln(g. for j:=1 to k do if (a[i].na do begin ok:=0. write(g. end.autor[j]=lista_autori[l]) then begin nr_titluri[l]:=nr_titluri[l]+1. for i:=1 to k-1 do for j:=i+1 to k do if (ord(lista_autori[i][1])>ord(lista_autori[j][1])) then begin auxs:=lista_autori[i]. {*************************************************************} k:=0. writeln(g).'2. si numarul de titluri este:'). edituri[k]:=a[i].lista_autori[i]).a[i]. nr_titluri[i]:=nr_titluri[j]. Lista autorilor ordonati alfabetic. nr_titluri[k]:=1. end. if (ok=0) then begin k:=k+1. ok:=1. '.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->