Creeaza.com - informatii profesionale despre


Evidentiem nevoile sociale din educatie - Referate profesionale unice



Acasa » referate » informatica » baze de date
PROIECT “Gestiunea studentilor”

PROIECT “Gestiunea studentilor”



Academia de Studii Economice

Bucuresti

Facultatea de Cibernetica, Statistica si Informatica Economica

Sectia Informatica Economica

Proiect

“Gestiunea studentilor”


               

Disciplina Structuri de Date

I. Indroducere

Prin acest proiect doresc sa realizez o gestiune a studentilor la sfarsitul anului II de studiu.

Pentru a face acest lucru voi folosi trei structuri de date, si anume:

-          masive unidimensionale;

-          liste dublu inlantuite;

-          fisiere;

Astfel, am realizat trei programe pascal independente, fiecare dintre ele rezolvand problema folosind una din structurile de date mentionate mai sus.

Pe langa acestea, am facut si un program monitor, care leaga cele trei programe, respectiv metode de rezolvare, printr-un meniu, in care se poate alege metoda dorita.

Aceasta gestiune a studentilor la sfarsitul anului II este necesara pentru impartirea studentilor pe sectii, conform optiunii lor si a mediei pe primii doi ani. Se pot adauga studenti la baza de date, se pot modifica datele studentilor aflati in gestiune, se pot scoate studenti din gestiune si se poate afisa continutul celor patru sectii in ordinea alfabetica.

            Folosirea celor trei structuri de date are scopul de a determina care metoda este mai buna, in functie de timpul de executie si memoria utilizata .

II. Descrierea problemei

            Datele de intrare folosite sunt citite dintr-un fisier de pe disc numit “stud.dat”. Acesta este folosit direct de pe disc la metoda fisierelor sau copiat in memorie in diferite structuri de date la celelalte metode.

            Datele de iesire sunt copiate intr-un fisier text pe disc, o data cu afisarea lor pe ecran. Aceasta operatie este efectuata indiferent de metoda utilizata, iar fisierul text este acelasi, denumit “rezultat.txt”. Ulterior poate fi listat pentru utilizarea rezultatelor.

            Algoritmul folosit este sortarea pe structurile de date utilizate. Timpul de executie care va fi calculat ia in considerare prelucrarea datelor, ceea ce inseamna sortarea, impartirea studentilor pe cele patru sectii si copierea in acestora in structura de date folosita pentru prima sectie, in cazul in care nu se afiseaza aceasta sectie.

III. Descrierea solutiei alese

Cele trei programe independente folosesc in comun fisierul “stud.dat”. Acesta poate fi creat numai prin metoda fisierelor si numai cand lipseste din directorul curent.

 Metoda fisierelor utilizeaza fisierul mentionat ca baza de date principala. Toate adaugarile, modificarile si stergerile se fac direct in acest fisier. Pentru afisarea sectiilor programul ordoneaza acest fisier in ordinea descrescatoare a mediei pe primii doi ani. Dupa aceasta sortare fisierul este parcurs si fiecare student este repartizat la prima sectie (ordinea de parcurgere a sectiilor este data de optiunea acestuia) la care mai sunt locuri disponibile. Sectiile sunt retinute in alte patru fisiere.

Pentru afisarea sectiei alese prin meniu, fisierul corespunzator este transferat intr-un fisier denumit  “comun.dat”, pentru o mai usoara comunicare intre proceduri si un cod mai redus, dupa care este apelata o procedura de formatare a ecranului.

Metoda masivelor unidimensionale incarca la inceput de pe disc intr-un masiv toti studenti aflati in gestiune. Prelucrarea datelor este realizata cu acest masiv, asemanator cu metoda fisierelor. Dimensiunea acestuia este limitata la numarul maxim al studentilor ce sunt intr-un an. Adaugarile, modificarile si stergerile datelor se fac pe acest masiv. Numai cand se face afisarea mai sunt introduse alte patru masive unidimensionale, pentru sectiile existente. Dimensiunea fiecaruia este egala cu numarul maxim de locuri ale sectiei pe care o reprezinta. Totusi, inainte de afisarea unei anumite sectii, datele dorite pentru listare nu sunt transferate intr-o alta structura de date ci in cea folosita pana atunci pentru sectia “Informatica Economica”, economisind astfel memorie si usurand comunicarea intre proceduri cat si codul.

Cand se termina cu aceasta metoda, vechiul fisier “stud.dat” este sters si refacut cu informatiile aflate in masivul principal.

Metoda listelor dublu inlantuite incarca deasemenea, la pornire, datele de pe disc intr-o lista dublu inlantuita, care va fi lista principala. Toate operatiile care se pot efectua o folosesc ca baza de date principala. Actualizarea bazei de date se va face pe aceasta, ca si ordonarea studentilor ce vor fi impartiti pe sectii cu metoda folosita mai inainte. Cele patru sectii vor fi reprezentate de alte patru liste dublu inlantuite. Pentru a lucra mai usor, daca se doreste afisare unei sectii diferita de “Informatica Economica” lista corespunzatoare este copiata in lista acestei sectii.

De asemenea, cand se inchide programul acestei metode, fisierul “stud.dat” de pe disc este refacut cu informatiile aflate in lista principala.

La metoda fisierelor si la metoda listelor dublu inlantuite, pentru a marca numarul maxim de elemente ce pot fi memorate s-au folosit cinci cuantificatori, unul pentru fisierul/lista principala si ceilalti pentru diferitele sectii. La metoda masivelor unidimensionale dimensiunea este data o data cu declararea acestora.

Toate cele trei programe sunt apelate de un program monitor prin intermediul unui meniu.

Masurarea timpilor de executie a diferitelor proceduri s-a realizat cu utilitarul Turbo Profiler iar masurarea dimensiunii codului si a memoriei ocupate cu utilitarul Turbo Compiler.   

IV. Textele sursa

Programul principal

(care reuneste cele trei solutii printr-un meniu)

program gestiune_studenti;

uses crt,dos;

var  is:boolean;

     c:char;

begin

repeat

clrscr;

is:=false;

repeat

gotoxy(15,10);writeln('1.Lucru cu fisiere');

gotoxy(15,11);writeln('2.Lucru cu vectori');

gotoxy(15,12);writeln('3.Lucru cu liste dublu inlantuite');

gotoxy(15,13);writeln('4.Terminare');

c:=readkey;

until c in ['1','2','3','4'];

swapvectors;

case c of

'1': exec('e:bpbinpaulfisiere.exe','');

'2': exec('e:bpbinpaulvectori.exe','');

'3': exec('e:bpbinpaulliste.exe','');

'4': is:=true;

end;

swapvectors;

until is;

end.

Metoda fisierelor:

program gestiune_studenti_fisiere;

uses crt;

type student=record

              Nume:string[15];

              Prenume:string[15];

              Nota1:real;

              Nota2:real;

              Optiune:array[1..4] of char;

              Media:real;

             end;

const alfabet=['A'..'Z',' '];

var f,fi,fc,fs,fm:file of student;

    ft:text;

    is,ct:boolean;

    er,i,j,p,l,k:byte;

    x,z,s:student;

    c,car,d:char;

    da:string[1];

    n:integer;

procedure eroare(sir:string;ab:byte);

begin

  gotoxy(2,15);writeln(sir,' --- Apasati spatiu');

  repeat  c:=readkey;  until c=' ';

  gotoxy(2,15);clreol;

  gotoxy(32,ab);clreol;

  er:=1;

end;

procedure format_ecran;

begin

gotoxy(5,5);writeln('Numele:');

gotoxy(5,6);writeln('Prenumele:');

gotoxy(5,7);writeln('Media pentru primul an:');

gotoxy(5,8);writeln('Media pentru al doilea an:');

gotoxy(5,9);writeln('Sectia dorita (I/C/S/M):');

end;

procedure valid_nume;

begin

repeat

  er:=0;

  gotoxy(32,5);readln(x.Nume);

  if length(x.Nume)>0 then

        begin

          for i:=1 to (length(x.Nume)) do

          if not(upcase(x.Nume[i]) in alfabet) then er:=1;

          if er=1 then eroare('Caractere nealfabetice!',5);

        end;

until er=0;

end;

procedure valid_prenume;

begin

repeat

er:=0;

gotoxy(32,6);readln(x.Prenume);

if length(x.Prenume)=0 then eroare('Camp vid!',6)

                    else

                      begin

                       for i:=1 to length(x.Prenume) do

                         if not(upcase(x.Prenume[i]) in alfabet) then er:=1;

                         if er=1 then eroare('Caractere nealfabetice!',6);

                      end;

until er=0;

end;

procedure valid_nota1;

begin

repeat

er:=0;

gotoxy(32,7);readln(x.Nota1);

if ioresult<>0 then eroare('Medie gresita!',7)

               else

                 if (x.Nota1<5) or (x.Nota1>10) then

                         eroare('Medie gresita!',7);

until er=0;

end;

procedure valid_nota2;

begin

repeat

er:=0;

gotoxy(32,8);readln(x.Nota2);

if ioresult<>0 then eroare('Medie gresita!',8)

               else

                 if (x.Nota2<5) or (x.Nota2>10) then

                         eroare('Medie gresita!',8);

until er=0;

end;

procedure valid_optiune;

var sir:string[7];

var k:byte;

begin

repeat

er:=0;

gotoxy(32,9);read(sir);

if (ioresult<>0) or (length(sir)<>7) or (sir[2]<>'/')

 or (sir[4]<>'/') or (sir[6]<>'/') then eroare('Greseala!',9)

   else

    begin

       for j:=1 to 4 do

          x.Optiune[j]:=' ';

       sir[2]:=sir[3];sir[3]:=sir[5];sir[4]:=sir[7];

       for p:=1 to 4 do

         begin

           k:=0;

           if (upcase(sir[p])<>'I') and (upcase(sir[p])<>'C') and

              (upcase(sir[p])<>'S') and (upcase(sir[p])<>'M') then k:=1;

           if k=0 then begin

                 for j:=1 to (p-1) do

                 if x.Optiune[j]=upcase(sir[p]) then k:=1;

               end;

           if k=1 then eroare('Sectie gresita!',9)

                                      else x.Optiune[p]:=upcase(sir[p]);

         end;

    end;

until er=0;

end;

procedure cautare(nume,prenume:string);

var il:byte;

begin

       reset(f);

       while (not(eof(f))) and (not ct) do

        begin

          read(f,s);

          if (s.Nume=nume) and (s.Prenume=prenume) then ct:=true;

        end;

end;

procedure introducere;

begin

  clrscr;

  format_ecran;

  repeat

   repeat

    ct:=false;

    valid_nume;

    if x.Nume<>'' then begin

                         valid_prenume;

                         cautare(x.Nume,x.Prenume);

                         if ct then begin

                                      eroare('Studentul deja exista in baza de date',5);

                                      gotoxy(32,5);clreol;

                                      gotoxy(32,6);clreol;

                                    end;

                       end;

   until (not ct) or (x.Nume='');

  if (not ct) and (x.Nume<>'') then

    begin

     valid_nota1;

     valid_nota2; valid_optiune;

     x.Media:=(x.Nota1+x.Nota2)/2;

     seek(f,filesize(f));write(f,x);

     window(1,1,80,25);

     gotoxy(2,15);

     writeln('Pentru terminare dati Numele vid!');

     window(32,5,80,12);clrscr;

     window(1,1,80,25);

     repeat c:=readkey; until c=' ';

     gotoxy(2,15);clreol;

   end;

  until x.Nume='';

readln;

end;

procedure prelucrare;

begin

clrscr;

       assign(f,'stud.dat');

       reset(f);

       if ioresult<>0 then begin

                            writeln('Fisierul nu exista!');

                            repeat c:=readkey; until c=' ';

                           end

                      else

       begin

         n:=filesize(f);

         if n>1 then

                begin

                 repeat

                  k:=0;

                  for i:=0 to n-2 do

                      begin

                      seek(f,i);read(f,x);read(f,z);

                      if x.Media<z.Media then begin

                                                seek(f,i);write(f,z);write(f,x);

                                                k:=1;

                                              end;

                      end;

                 until k=0;

               end;

        reset(f);

        assign(fi,'info.dat');rewrite(fi);

        assign(fc,'cib.dat');rewrite(fc);

        assign(fs,'stat.dat');rewrite(fs);

        assign(fm,'mate.dat');rewrite(fm);

        for i:=0 to (n-1) do

         begin

          read(f,x);

          k:=0;j:=1;

          repeat

           if (x.Optiune[j]='I') and (filesize(fi)<135) then begin

                                                               write(fi,x);

                                                               k:=1;

                                                             end;

           if (x.Optiune[j]='C') and (filesize(fc)<135) then begin

                                                              write(fc,x);

                                                              k:=1;

                                                             end;

           if (x.Optiune[j]='S') and (filesize(fs)<100) then begin

                                                              write(fs,x);

                                                              k:=1;

                                                             end;

           if (x.Optiune[j]='M') and (filesize(fm)<40) then begin

                                                             write(fm,x);

                                                             k:=1;

                                                            end;

           inc(j);

          until k=1;

         end;

         close(f);close(fi);close(fc);close(fs);close(fm);

       end;

end;

procedure creare;

begin

clrscr;

assign(f,'stud.dat');

reset(f);

if ioresult<>0 then

                begin

                  rewrite(f);

                  gotoxy(7,3);writeln('Fisier: stud.dat');

                  introducere;

                end

                else

                 begin

                   writeln('Fisierul exista!');

                   repeat

                   c:=readkey;

                   until c=' ';

                   close(f);

                 end;

end;

procedure afisare(h:byte);forward;

procedure ordonare(h:byte);

begin

clrscr;

prelucrare;

      assign(f,'comun.dat');

      rewrite(f);

      case h of

      1: begin

          assign(fi,'info.dat');reset(fi);

          while not eof(fi) do

            begin

              read(fi,x);write(f,x);

            end;

          close(fi);erase(fi);

         end;

      2: begin

          assign(fc,'cib.dat');reset(fc);

          while not eof(fc) do

            begin

             read(fc,x);write(f,x);

            end;

          close(fc);erase(fc);

         end;

      3: begin

          assign(fs,'stat.dat');reset(fs);

          while not eof(fs) do

            begin

             read(fs,x);write(f,x);

            end;

          close(fs);erase(fs);

         end;

      4: begin

          assign(fm,'mate.dat');reset(fm);

          while not eof(fm) do

            begin

             read(fm,x);write(f,x);

            end;

          close(fm);erase(fm);

         end;

      end;

      reset(f);

      n:=filesize(f);

      repeat

       k:=0;

       if n>1 then

         for i:=0 to n-2 do

          begin

            seek(f,i);read(f,x);read(f,z);

            if (x.Nume+x.Prenume)>(z.Nume+z.Prenume) then

                             begin

                               seek(f,i);write(f,z);write(f,x);

                               k:=1;

                             end;

          end;

      until k=0;

      close(f);

      afisare(h);

end;

procedure afisare(h:byte);

begin

clrscr;

gotoxy(20,2);

assign(ft,'rezultat.txt');

rewrite(ft);

case h of

1: begin

    writeln('Informatica economica');

    writeln(ft,'                          Informatica economica');

   end;

2: begin

    writeln('Cibernetica');

    writeln(ft,'                          Cibernetica');

   end;

3: begin

    writeln('Statistica');

    writeln(ft,'                          Statistica');

   end;

4: begin

    writeln('Matematica economica');

    writeln(ft,'                          Matematica economica');

   end;

end;

for i:=1 to 3 do writeln(ft,' ');

gotoxy(1,5);write('É');write(ft,'É');

for i:=1 to 71 do begin

                    write('Í');

                    write(ft,'Í');

                  end;

writeln('»');writeln(ft,'»');

gotoxy(1,6);write('s');write('Nr. ');write('      Nume      ');write('    Prenume    ');

write('  Medie I ');write(' Medie II ');write(' Optiune ');write('  Media');writeln('s');

gotoxy(1,7);write('Ì');for i:=1 to 71 do write('Í');writeln('¹');

write(ft,'s');write(ft,'Nr. ');write(ft,'      Nume      ');write(ft,'    Prenume    ');

write(ft,'  Medie I ');write(ft,' Medie II ');write(ft,' Optiune ');write(ft,'  Media');writeln(ft,'s');

write(ft,'Ì');for i:=1 to 71 do write(ft,'Í');writeln(ft,'¹');

      assign(f,'comun.dat');

      reset(f);

      n:=filesize(f);

      k:=1;

      for i:=1 to n do

       begin

        if k<17 then

        begin

        read(f,x);

        gotoxy(1,7+k);

        write('s');write(i);

        write(ft,'s');str(i,da);write(ft,da);for j:=1 to (3-length(da)) do write(ft,' ');

        gotoxy(6,7+k);write(x.Nume);gotoxy(23,7+k);write(x.Prenume);

        gotoxy(40,7+k);write(x.Nota1:2:2);gotoxy(51,7+k);write(x.Nota2:2:2);

        gotoxy(58,7+k);write(x.Optiune[1],'/',x.Optiune[2],'/',x.Optiune[3],'/',x.Optiune[4]);

        gotoxy(68,7+k);write(x.Media:5:2);write('s');

        write(ft,x.Nume);for j:=1 to (15-length(x.Nume)) do write(ft,' ');

        write(ft,x.Prenume);for j:=1 to (15-length(x.Prenume)) do write(ft,' ');

        write(ft,'     ',x.Nota1:2:2,'      ');write(ft,x.Nota2:2:2,'    ');

        write(ft,x.Optiune[1],'/',x.Optiune[2],'/',x.Optiune[3],'/',x.Optiune[4]);

        write(ft,'   ',x.Media:5:2);writeln(ft,'s');

        k:=k+1;

        end

        else

        begin

         gotoxy(1,7+k);write('È');for j:=1 to 26 do write('Í');

         write('Apasati spatiu');for j:=41 to 66 do write('Í');

         writeln('¼');

         repeat c:=readkey; until c=' ';

         window(2,8,79,23);clrscr;

         window(1,1,80,25);

         k:=1;

        end;

       end;

     if k<>1 then

        begin

         gotoxy(1,k+7);write('È');for j:=1 to 71 do write('Í');writeln('¼');

        end;

     gotoxy(20,23);write('Apasati Spatiu');

     write(ft,'È');for j:=1 to 71 do write(ft,'Í');writeln(ft,'¼');

     repeat c:=readkey; until c=' ';

     close(ft);

end;

procedure adaugare;

begin

clrscr;

assign(f,'stud.dat');

reset(f);

if ioresult<>0 then begin

                      writeln('Fisierul nu exista!');

                      repeat

                      c:=readkey;



                      until c=' ';

                    end

                    else

                      begin

                        gotoxy(7,2);writeln('Fisier: stud.dat');

                        introducere;

                      end;

close(f);

end;

procedure modificare;

var poz:byte;

begin

clrscr;

     assign(f,'stud.dat');

     reset(f);

     if ioresult<>0 then

     begin

       writeln('Fisierul nu exista!');

       repeat c:=readkey; until c=' ';

     end

     else

      begin

        clrscr;

        gotoxy(7,2);writeln('Fisier: stud.dat');

        gotoxy(2,3);writeln('Dati numele si prenumele studentului cautat!');

        format_ecran;

        repeat

         valid_nume;

         if x.Nume<>'' then valid_prenume;

         k:=0;

         while (not eof(f)) and (k=0) and (x.Nume<>'') do

         begin

          read(f,z);

          if (x.Nume+x.Prenume)=(z.Nume+z.Prenume) then

                             begin

                              k:=1;

                              poz:=filepos(f)-1;

                             end;

         end;

         if (k=0) and (x.Nume<>'') then eroare('Studentul nu este in baza de date!',5);

        until (k=1) or (x.Nume='');

        if k=1 then

              begin

               window(32,5,80,12);clrscr;

               window(1,1,80,25);

               eroare('Introduceti articolul modificat!',5);

               valid_nume;valid_prenume;

               valid_nota1;valid_nota2;

               valid_optiune;x.Media:=(x.Nota1+x.Nota2)/2;

               seek(f,poz);write(f,x);

              end;

        close(f);

      end;

end;

procedure stergere;

var poz:byte;

begin

clrscr;

     assign(f,'stud.dat');

     reset(f);

     if ioresult<>0 then

       begin

         writeln('Fisierul nu exista!');

         repeat c:=readkey; until c=' ';

       end

       else

        begin

         gotoxy(1,1);clreol;

         gotoxy(7,2);writeln('Fisier: stud.dat');

         gotoxy(2,3);writeln('Dati numele si prenumele studentului cautat!');

         format_ecran;

         k:=0;

         repeat

          valid_nume;

          if x.Nume<>'' then valid_prenume;

          i:=0;

          if x.Nume<>'' then

                     begin

                      while (not eof(f)) and (k=0) do

                      begin

                       read(f,z);

                       if (x.Nume+x.Prenume)=(z.Nume+z.Prenume) then

                                               begin

                                                 k:=1;

                                                 poz:=filepos(f)-1;

                                               end;

                      end;

                      if k=0 then eroare('Codul nu exista!',5);

                     end;

         until (k=1) or (x.Nume='');

         if x.Nume<>'' then begin

                          gotoxy(2,3);clreol;

                          gotoxy(2,3);writeln('Studentul care va fi sters este:');

                          seek(f,poz);read(f,x);

                          gotoxy(32,5);writeln(x.Nume);

                          gotoxy(32,6);writeln(x.Prenume);

                          gotoxy(32,7);writeln(x.Nota1:2:2);

                          gotoxy(32,8);writeln(x.Nota2:2:2);

                          gotoxy(32,9);

                          for i:=1 to 3 do

                            write(x.Optiune[i],'/');

                          writeln(x.Optiune[4]);

                          gotoxy(2,15);writeln('Se confirma stergerea (Y/N)?');

                          repeat c:=readkey; until c in ['Y','y','N','n'];

                          if c in ['Y','y'] then

                                   begin

                                     seek(f,(filesize(f)-1));

                                     read(f,z);

                                     seek(f,poz);write(f,z);

                                     seek(f,(filesize(f)-1));

                                     truncate(f);

                                   end;

                          end;

         close(f);

           end;

end;

begin

repeat

 clrscr;

 is:=false; 

 repeat

  gotoxy(1,1);writeln('1.Crearea unui fisier nou (numai cu fisiere)');

  gotoxy(1,2);writeln('2.Afisare sectie');

  gotoxy(1,3);writeln('3.Actualizare');

  gotoxy(1,4);writeln('4.Terminare');

  c:=readkey;

 until c in ['1','2','3','4'];

case c of

   '1': creare;

   '2': begin

        repeat

           gotoxy(22,2);writeln('--->  1.Informatica Economica');

           gotoxy(22,3);writeln('      2.Cibernetica');

           gotoxy(22,4);writeln('      3.Statistica economica');

           gotoxy(22,5);writeln('      4.Matematica economica');

           gotoxy(22,6);writeln('      5.Anulare');

           d:=readkey;

        until d in ['1','2','3','4','5'];

        window(22,2,80,10);clrscr;

        window(1,1,80,23);

        case d of

          '1':ordonare(1);

          '2':ordonare(2);

          '3':ordonare(3);

          '4':ordonare(4);

          '5':begin end;

        end;

        end;

   '3': begin

          repeat

            gotoxy(22,3);writeln('--->  1.Adaugare student');

            gotoxy(22,4);writeln('      2.Modificare');

            gotoxy(22,5);writeln('      3.Stergere student');

            gotoxy(22,6);writeln('      4.Anulare');

            d:=readkey;

          until d in ['1','2','3','4'];

          window(22,3,80,8);clrscr;

          window(1,1,80,23);

          case d of

             '1': adaugare;

             '2': modificare;

             '3': stergere;

             '4': begin end;

           end;

        end;

    '4': is:=true;

    end;

until is;

end.

Metoda vectorilor:

program gestiune_studenti_vectori;

uses crt;

type student=record

              Nume:string[15];

              Prenume:string[15];

              Nota1:real;

              Nota2:real;

              Optiune:array[1..4] of char;

              Media:real;

             end;

const alfabet=['A'..'Z',' '];

var f:file of student;

    ft:text;

    v:array[0..409] of student;

    vi,vc:array[0..134] of student;

    vs:array[0..99] of student;

    vm:array[0..39] of student;

    is,ct:boolean;

    er,i,p,j,l,k,il:byte;

    x,z,s:student;

    c,car,d:char;

    da:string[1];

    max,maxi,maxc,maxs,maxm:integer;

procedure eroare(sir:string;ab:byte);

begin

  gotoxy(2,15);writeln(sir,' --- Apasati spatiu');

  repeat  c:=readkey;  until c=' ';

  gotoxy(2,15);clreol;

  gotoxy(32,ab);clreol;

  er:=1;

end;

procedure format_ecran;

begin

gotoxy(5,5);writeln('Numele:');

gotoxy(5,6);writeln('Prenumele:');

gotoxy(5,7);writeln('Media pentru primul an:');

gotoxy(5,8);writeln('Media pentru al doilea an:');

gotoxy(5,9);writeln('Sectia dorita (I/C/S/M):');

end;

procedure valid_nume;

begin

repeat

  er:=0;

  gotoxy(32,5);readln(x.Nume);

  if length(x.Nume)>0 then

        begin

          for i:=1 to (length(x.Nume)) do

          if not(upcase(x.Nume[i]) in alfabet) then er:=1;

          if er=1 then eroare('Caractere nealfabetice!',5);

        end;

until er=0;

end;

procedure valid_prenume;

begin

repeat

er:=0;

gotoxy(32,6);readln(x.Prenume);

if length(x.Prenume)=0 then eroare('Camp vid!',6)

                    else

                      begin

                       for i:=1 to length(x.Prenume) do

                         if not(upcase(x.Prenume[i]) in alfabet) then er:=1;

                         if er=1 then eroare('Caractere nealfabetice!',6);

                      end;

until er=0;

end;

procedure valid_nota1;

begin

repeat

er:=0;

gotoxy(32,7);readln(x.Nota1);

if ioresult<>0 then eroare('Medie gresita!',7)

               else

                 if (x.Nota1<5) or (x.Nota1>10) then

                         eroare('Medie gresita!',7);

until er=0;

end;

procedure valid_nota2;

begin

repeat

er:=0;

gotoxy(32,8);readln(x.Nota2);

if ioresult<>0 then eroare('Medie gresita!',8)

               else

                 if (x.Nota2<5) or (x.Nota2>10) then

                         eroare('Medie gresita!',8);

until er=0;

end;

procedure valid_optiune;

var sir:string[7];

var k:byte;

begin

repeat

er:=0;

gotoxy(32,9);read(sir);

if (ioresult<>0) or (length(sir)<>7) or (sir[2]<>'/')

 or (sir[4]<>'/') or (sir[6]<>'/') then eroare('Greseala!',9)

   else

    begin

       for j:=1 to 4 do

          x.Optiune[j]:=' ';

       sir[2]:=sir[3];sir[3]:=sir[5];sir[4]:=sir[7];

       for p:=1 to 4 do

         begin

           k:=0;

           if (upcase(sir[p])<>'I') and (upcase(sir[p])<>'C') and

              (upcase(sir[p])<>'S') and (upcase(sir[p])<>'M') then k:=1;

           if k=0 then begin

                 for j:=1 to (p-1) do

                 if x.Optiune[j]=upcase(sir[p]) then k:=1;

               end;

           if k=1 then eroare('Sectie gresita!',9)

                                      else x.Optiune[p]:=upcase(sir[p]);

         end;

    end;

until er=0;

end;

procedure cautare(nume,prenume:string);

var il:byte;

begin

       il:=0;

       while (il<=max) and (not ct) do

        begin

          if (v[il].Nume=nume) and (v[il].Prenume=prenume) then ct:=true;

          inc(il);

        end;

end;

procedure prelucrare;

begin

clrscr;

         if max>0 then

                begin

                 repeat

                  k:=0;

                  for i:=0 to max-1 do

                      if v[i].Media<v[i+1].Media then begin

                                                       x:=v[i];

                                                       v[i]:=v[i+1];

                                                       v[i+1]:=x;

                                                       k:=1;

                                                      end;

                 until k=0;

               end;

        maxi:=-1;maxc:=-1;maxs:=-1;maxm:=-1;

        for i:=0 to max do

         begin

          k:=0;j:=1;

          repeat

           if (v[i].Optiune[j]='I') and (maxi<134) then begin

                                                           inc(maxi);

                                                           vi[maxi]:=v[i];

                                                           k:=1;

                                                        end;

           if (v[i].Optiune[j]='C') and (maxc<134) then begin

                                                          inc(maxc);

                                                          vc[maxc]:=v[i];

                                                          k:=1;

                                                        end;

           if (v[i].Optiune[j]='S') and (maxs<99) then begin

                                                         inc(maxs);

                                                         vs[maxs]:=v[i];

                                                         k:=1;

                                                       end;

           if (v[i].Optiune[j]='M') and (maxm<39) then begin

                                                         inc(maxm);

                                                         vm[maxm]:=v[i];

                                                         k:=1;

                                                       end;

           inc(j);

          until k=1;

         end;

end;

procedure afisare(h:byte);forward;

procedure ordonare(h:byte);

begin

clrscr;

prelucrare;

      case h of

      1: begin

         end;

      2: begin

          il:=0;

          while il<=maxc do

            begin

             vi[il]:=vc[il];

             inc(il);

            end;

          maxi:=maxc;

         end;

      3: begin

          il:=0;

          while il<=maxs do

            begin

             vi[il]:=vs[il];

             inc(il);

            end;

         maxi:=maxs;

         end;

      4: begin

          il:=0;

          while il<=maxm do

            begin

             vi[il]:=vm[il];

             inc(il);

            end;

          maxi:=maxm;

         end;

      end;

      if maxi>0 then

      repeat

       k:=0;

         for i:=0 to maxi-1 do

          begin

            if (vi[i].Nume+vi[i].Prenume)>(vi[i+1].Nume+vi[i+1].Prenume) then

                             begin

                               x:=vi[i];

                               vi[i]:=vi[i+1];

                               vi[i+1]:=x;

                               k:=1;

                             end;

          end;

      until k=0;

      afisare(h);

end;

procedure afisare(h:byte);

begin

clrscr;

gotoxy(20,2);

assign(ft,'rezultat.txt');

rewrite(ft);

case h of

1: begin

    writeln('Informatica economica');

    writeln(ft,'                          Informatica economica');

   end;

2: begin

    writeln('Cibernetica');

    writeln(ft,'                          Cibernetica');

   end;

3: begin

    writeln('Statistica');

    writeln(ft,'                          Statistica');

   end;

4: begin

    writeln('Matematica economica');

    writeln(ft,'                          Matematica economica');

   end;

end;

for i:=1 to 3 do writeln(ft,' ');

gotoxy(1,5);write('É');write(ft,'É');

for i:=1 to 71 do begin

                    write('Í');

                    write(ft,'Í');

                  end;

writeln('»');writeln(ft,'»');

gotoxy(1,6);write('s');write('Nr. ');write('      Nume      ');write('    Prenume    ');

write('  Medie I ');write(' Medie II ');write(' Optiune ');write('  Media');writeln('s');

gotoxy(1,7);write('Ì');for i:=1 to 71 do write('Í');writeln('¹');

write(ft,'s');write(ft,'Nr. ');write(ft,'      Nume      ');write(ft,'    Prenume    ');

write(ft,'  Medie I ');write(ft,' Medie II ');write(ft,' Optiune ');write(ft,'  Media');writeln(ft,'s');

write(ft,'Ì');for i:=1 to 71 do write(ft,'Í');writeln(ft,'¹');

      k:=1;

      for i:=1 to (maxi+1) do

       begin

        if k<17 then

        begin

         x:=vi[i-1];

         gotoxy(1,7+k);

         write('s');write(i);

         write(ft,'s');str(i,da);write(ft,da);for j:=1 to (3-length(da)) do write(ft,' ');

         gotoxy(6,7+k);write(x.Nume);gotoxy(23,7+k);write(x.Prenume);

         gotoxy(40,7+k);write(x.Nota1:2:2);gotoxy(51,7+k);write(x.Nota2:2:2);

         gotoxy(58,7+k);write(x.Optiune[1],'/',x.Optiune[2],'/',x.Optiune[3],'/',x.Optiune[4]);

         gotoxy(68,7+k);write(x.Media:5:2);write('s');

         write(ft,x.Nume);for j:=1 to (15-length(x.Nume)) do write(ft,' ');

         write(ft,x.Prenume);for j:=1 to (15-length(x.Prenume)) do write(ft,' ');

         write(ft,'     ',x.Nota1:2:2,'      ');write(ft,x.Nota2:2:2,'    ');

         write(ft,x.Optiune[1],'/',x.Optiune[2],'/',x.Optiune[3],'/',x.Optiune[4]);

         write(ft,'   ',x.Media:5:2);writeln(ft,'s');

         k:=k+1;

        end

        else

        begin

         gotoxy(1,7+k);write('È');for j:=1 to 26 do write('Í');

         write('Apasati spatiu');for j:=41 to 66 do write('Í');

         writeln('¼');

         repeat c:=readkey; until c=' ';

         window(2,8,79,23);clrscr;

         window(1,1,80,25);

         k:=1;

        end;

       end;

       if k<>1 then

        begin

         gotoxy(1,k+7);write('È');for j:=1 to 71 do write('Í');writeln('¼');

        end;

         gotoxy(20,23);write('Apasati Spatiu');

         write(ft,'È');for j:=1 to 71 do write(ft,'Í');writeln(ft,'¼');

         repeat c:=readkey; until c=' ';

         close(ft);

end;

procedure adaugare;



begin

clrscr;

gotoxy(7,2);writeln('Baza de date: stud.dat');

format_ecran;

  repeat

   repeat

    ct:=false;

    valid_nume;

    if x.Nume<>'' then begin

                         valid_prenume;



                         cautare(x.Nume,x.Prenume);

                         if ct then begin

                                      eroare('Studentul deja exista in baza de date',5);

                                      gotoxy(32,5);clreol;

                                      gotoxy(32,6);clreol;

                                    end;

                       end;

   until (not ct) or (x.Nume='');

  if (not ct) and (x.Nume<>'') then

    begin

     valid_nota1;

     valid_nota2; valid_optiune;

     x.Media:=(x.Nota1+x.Nota2)/2;

     max:=max+1;v[max]:=x;

     window(1,1,80,25);

     gotoxy(2,15);

     writeln('Pentru terminare dati Numele vid!');

     window(32,5,80,12);clrscr;

     window(1,1,80,25);

     repeat c:=readkey; until c=' ';

     gotoxy(2,15);clreol;

   end;

  until x.Nume='';

readln;

end;

procedure modificare;

var poz:byte;

begin

    clrscr;

    gotoxy(7,2);writeln('Baza de date stud');

    gotoxy(2,3);writeln('Dati numele si prenumele studentului cautat!');

    format_ecran;

    repeat

     valid_nume;

     if x.Nume<>'' then valid_prenume;

     k:=0;il:=0;

     while (il<=max) and (k=0) and (x.Nume<>'') do

       begin

        if (x.Nume+x.Prenume)=(v[il].Nume+v[il].Prenume) then

                             begin

                              k:=1;

                              poz:=il;

                             end;

        inc(il);

       end;

     if (k=0) and (x.Nume<>'') then eroare('Studentul nu este in baza de date!',5);

    until (k=1) or (x.Nume='');

    if k=1 then

              begin

               window(32,5,80,12);clrscr;

               window(1,1,80,25);

               eroare('Introduceti articolul modificat!',5);

               valid_nume;valid_prenume;

               valid_nota1;valid_nota2;

               valid_optiune;x.Media:=(x.Nota1+x.Nota2)/2;

               v[poz]:=x;

              end;

end;

procedure stergere;

var poz:byte;

begin

clrscr;

      gotoxy(1,1);clreol;

      gotoxy(7,2);writeln('Baza de date stud');

      gotoxy(2,3);writeln('Dati numele si prenumele studentului cautat!');

      format_ecran;

      k:=0;

      repeat

      valid_nume;

      if x.Nume<>'' then valid_prenume;

      i:=0;

      if x.Nume<>'' then

                     begin

                      il:=0;

                      while (il<=max) and (k=0) do

                      begin

                       if (x.Nume+x.Prenume)=(v[il].Nume+v[il].Prenume) then

                                               begin

                                                 k:=1;

                                                 poz:=il;

                                               end;

                       inc(il);

                      end;

                      if k=0 then eroare('Codul nu exista!',5);

                     end;

      until (k=1) or (x.Nume='');

      if x.Nume<>'' then begin

                          gotoxy(2,3);clreol;

                          gotoxy(2,3);writeln('Studentul care va fi sters este:');

                          x:=v[poz];

                          gotoxy(32,5);writeln(x.Nume);

                          gotoxy(32,6);writeln(x.Prenume);

                          gotoxy(32,7);writeln(x.Nota1:2:2);

                          gotoxy(32,8);writeln(x.Nota2:2:2);

                          gotoxy(32,9);

                          for i:=1 to 3 do

                            write(x.Optiune[i],'/');

                          writeln(x.Optiune[4]);

                          gotoxy(2,15);writeln('Se confirma stergerea (Y/N)?');

                          repeat c:=readkey; until c in ['Y','y','N','n'];

                          if c in ['Y','y'] then

                                   begin

                                     v[poz]:=v[max];

                                     max:=max-1;

                                   end;

                         end;

end;

begin

clrscr;

      assign(f,'stud.dat');

      reset(f);

      if ioresult<>0 then begin

                           writeln('Baza de date nu exista si nu poate fi incarcata!');

                           repeat c:=readkey; until c=' ';

                          end

                     else

begin

i:=0;

while not eof(f) do

   begin

     read(f,x);

     v[i]:=x;

     inc(i);

   end;

max:=i-1;

close(f);

repeat  

 clrscr;

 is:=false;  

 repeat

  gotoxy(1,1);writeln('1.Crearea unui fisier nou (numai cu fisiere)');

  gotoxy(1,2);writeln('2.Afisare sectie');

  gotoxy(1,3);writeln('3.Actualizare');

  gotoxy(1,4);writeln('4.Terminare');

  c:=readkey;

 until c in ['1','2','3','4'];

case c of

   '1': begin

        end;

   '2': begin

        repeat

           gotoxy(22,2);writeln('--->  1.Informatica Economica');

           gotoxy(22,3);writeln('      2.Cibernetica');

           gotoxy(22,4);writeln('      3.Statistica economica');

           gotoxy(22,5);writeln('      4.Matematica economica');

           gotoxy(22,6);writeln('      5.Anulare');

           d:=readkey;

        until d in ['1','2','3','4','5'];

        window(22,2,80,10);clrscr;

        window(1,1,80,23);

        case d of

          '1':ordonare(1);

          '2':ordonare(2);

          '3':ordonare(3);

          '4':ordonare(4);

          '5':begin end;

        end;

        end;

   '3': begin

          repeat

            gotoxy(22,3);writeln('--->  1.Adaugare student');

            gotoxy(22,4);writeln('      2.Modificare');

            gotoxy(22,5);writeln('      3.Stergere student');

            gotoxy(22,6);writeln('      4.Anulare');

            d:=readkey;

          until d in ['1','2','3','4'];

          window(22,3,80,8);clrscr;

          window(1,1,80,23);

          case d of

             '1': adaugare;

             '2': modificare;

             '3': stergere;

             '4': begin end;

           end;

        end;

    '4': begin

           assign(f,'stud.dat');

           rewrite(f);

           for i:=0 to max do

               write(f,v[i]);

           close(f);

           is:=true;

         end;

    end;

until is;

end;

end.

Metoda listelor dublu inlantuite:

program gestiune_studenti_liste;

uses crt;

type student=record

              Nume:string[15];

              Prenume:string[15];

              Nota1:real;

              Nota2:real;

              Optiune:array[1..4] of char;

              Media:real;

             end;

      comp=^elem;

      elem=record

            inf:student;

            pred,succ:comp;

           end;

const alfabet=['A'..'Z',' '];

var f:file of student;

    ft:text;

    incb,sf,inci,sfi,incc,sfc,incs,sfs,incm,sfm,b,e:comp;

    is,ct:boolean;

    er,i,j,p,l,k:byte;

    x,z,s:student;

    c,car,d:char;

    da:string[1];

    max,maxi,maxc,maxs,maxm:integer;

procedure eroare(sir:string;ab:byte);

begin

  gotoxy(2,15);writeln(sir,' --- Apasati spatiu');

  repeat  c:=readkey;  until c=' ';

  gotoxy(2,15);clreol;

  gotoxy(32,ab);clreol;

  er:=1;

end;

procedure format_ecran;

begin

gotoxy(5,5);writeln('Numele:');

gotoxy(5,6);writeln('Prenumele:');

gotoxy(5,7);writeln('Media pentru primul an:');

gotoxy(5,8);writeln('Media pentru al doilea an:');

gotoxy(5,9);writeln('Sectia dorita (I/C/S/M):');

end;

procedure valid_nume;

begin

repeat

  er:=0;

  gotoxy(32,5);readln(x.Nume);

  if length(x.Nume)>0 then

        begin

          for i:=1 to (length(x.Nume)) do

          if not(upcase(x.Nume[i]) in alfabet) then er:=1;

          if er=1 then eroare('Caractere nealfabetice!',5);

        end;

until er=0;

end;

procedure valid_prenume;

begin

repeat

er:=0;

gotoxy(32,6);readln(x.Prenume);

if length(x.Prenume)=0 then eroare('Camp vid!',6)

                    else

                      begin

                       for i:=1 to length(x.Prenume) do

                         if not(upcase(x.Prenume[i]) in alfabet) then er:=1;

                         if er=1 then eroare('Caractere nealfabetice!',6);

                      end;

until er=0;

end;

procedure valid_nota1;

begin

repeat

er:=0;

gotoxy(32,7);readln(x.Nota1);

if ioresult<>0 then eroare('Medie gresita!',7)

               else

                 if (x.Nota1<5) or (x.Nota1>10) then

                         eroare('Medie gresita!',7);

until er=0;

end;

procedure valid_nota2;

begin

repeat

er:=0;

gotoxy(32,8);readln(x.Nota2);

if ioresult<>0 then eroare('Medie gresita!',8)

               else

                 if (x.Nota2<5) or (x.Nota2>10) then

                         eroare('Medie gresita!',8);

until er=0;

end;

procedure valid_optiune;

var sir:string[7];

var k:byte;

begin

repeat

er:=0;

gotoxy(32,9);read(sir);

if (ioresult<>0) or (length(sir)<>7) or (sir[2]<>'/')

 or (sir[4]<>'/') or (sir[6]<>'/') then eroare('Greseala!',9)

   else

    begin

       for j:=1 to 4 do

          x.Optiune[j]:=' ';

       sir[2]:=sir[3];sir[3]:=sir[5];sir[4]:=sir[7];

       for p:=1 to 4 do

         begin

           k:=0;

           if (upcase(sir[p])<>'I') and (upcase(sir[p])<>'C') and

              (upcase(sir[p])<>'S') and (upcase(sir[p])<>'M') then k:=1;

           if k=0 then begin

                 for j:=1 to (p-1) do

                 if x.Optiune[j]=upcase(sir[p]) then k:=1;

               end;

           if k=1 then eroare('Sectie gresita!',9)

                                      else x.Optiune[p]:=upcase(sir[p]);

         end;

    end;

until er=0;

end;

procedure cautare(nume,prenume:string);

var il:byte;

begin

      b:=incb^.succ;

      while (b<>sf) and (not ct) do

       begin

         if (b^.inf.Nume=nume) and (b^.inf.Prenume=prenume) then ct:=true;

         b:=b^.succ;

       end;

end;

procedure prelucrare;

begin

clrscr;

         if incb^.succ<>sf then

                begin

                 repeat

                  k:=0;

                   b:=incb^.succ;

                   while b<>sf^.pred do

                      begin

                      if b^.inf.Media<b^.succ^.inf.Media then

                                                      begin

                                                       x:=b^.inf;

                                                       b^.inf:=b^.succ^.inf;

                                                       b^.succ^.inf:=x;

                                                       k:=1;

                                                      end;

                      b:=b^.succ;

                      end;

                 until k=0;

               end;

        new(inci);new(sfi);inci^.succ:=sfi;sfi^.pred:=inci;maxi:=0;

        new(incc);new(sfc);incc^.succ:=sfc;sfc^.pred:=incc;maxc:=0;

        new(incs);new(sfs);incs^.succ:=sfs;sfs^.pred:=incs;maxs:=0;

        new(incm);new(sfm);incm^.succ:=sfm;sfm^.pred:=incm;maxm:=0;

        b:=incb^.succ;

        while b<>sf do

         begin

          k:=0;j:=1;

          repeat

           if (b^.inf.Optiune[j]='I') and (maxi<135) then begin

                                                           inc(maxi);

                                                           e:=sfi;

                                                           new(sfi);

                                                           e^.inf:=b^.inf;

                                                           sfi^.pred:=e;

                                                           e^.succ:=sfi;

                                                           k:=1;

                                                          end;

           if (b^.inf.Optiune[j]='C') and (maxc<135) then begin

                                                          inc(maxc);

                                                          e:=sfc;

                                                          new(sfc);

                                                          e^.inf:=b^.inf;

                                                          sfc^.pred:=e;

                                                          e^.succ:=sfc;

                                                          k:=1;

                                                        end;

           if (b^.inf.Optiune[j]='S') and (maxs<100) then begin

                                                            inc(maxs);

                                                            e:=sfs;

                                                            new(sfs);

                                                            e^.inf:=b^.inf;

                                                            sfs^.pred:=e;

                                                            e^.succ:=sfs;

                                                            k:=1;

                                                          end;

           if (b^.inf.Optiune[j]='M') and (maxm<40) then begin

                                                           inc(maxm);

                                                           e:=sfm;

                                                           new(sfm);

                                                           e^.inf:=b^.inf;

                                                           sfm^.pred:=e;

                                                           e^.succ:=sfm;

                                                           k:=1;

                                                         end;

           inc(j);

          until k=1;

          b:=b^.succ;

         end;

end;

procedure afisare(h:byte);forward;

procedure ordonare(h:byte);

begin

clrscr;

prelucrare;

      case h of

      1: begin

         end;

      2: begin

          e:=incc^.succ;

          b:=inci^.succ;

          while e<>sfc do

            begin

             b^.inf:=e^.inf;

             b:=b^.succ;

             e:=e^.succ;

            end;

          sfi:=b;

         end;

      3: begin

          e:=incs^.succ;

          b:=inci^.succ;

          while e<>sfs do

            begin

             b^.inf:=e^.inf;

             b:=b^.succ;

             e:=e^.succ;

            end;

          sfi:=b;

         end;

      4: begin

          e:=incm^.succ;

          b:=inci^.succ;

          while e<>sfm do

            begin

             b^.inf:=e^.inf;

             b:=b^.succ;

             e:=e^.succ;

            end;

         sfi:=b;

         end;

      end;

      if inci^.succ<>sfi then

      repeat

       k:=0;

         b:=inci^.succ;

         while b<>sfi^.pred do

          begin

            if (b^.inf.Nume+b^.inf.Prenume)>(b^.succ^.inf.Nume+b^.succ^.inf.Prenume) then

                             begin

                               x:=b^.inf;

                               b^.inf:=b^.succ^.inf;

                               b^.succ^.inf:=x;

                               k:=1;

                             end;

          b:=b^.succ;

          end;

      until k=0;

      afisare(h);

end;

procedure afisare(h:byte);

begin

clrscr;

gotoxy(20,2);

assign(ft,'rezultat.txt');

rewrite(ft);

case h of

1: begin

    writeln('Informatica economica');

    writeln(ft,'                         Informatica economica');

   end;

2: begin

    writeln('Cibernetica');

    writeln(ft,'                    Cibernetica');

   end;

3: begin

    writeln('Statistica');

    writeln(ft,'                    Statistica');

   end;

4: begin

    writeln('Matematica economica');

    writeln(ft,'                    Matematica economica');

   end;

end;

for i:=1 to 3 do writeln(ft,' ');

gotoxy(1,5);write('É');write(ft,'É');

for i:=1 to 71 do begin

                    write('Í');

                    write(ft,'Í');

                  end;

writeln('»');writeln(ft,'»');

gotoxy(1,6);write('s');write('Nr. ');write('      Nume      ');write('    Prenume    ');

write('  Medie I ');write(' Medie II ');write(' Optiune ');write('  Media');writeln('s');



gotoxy(1,7);write('Ì');for i:=1 to 71 do write('Í');writeln('¹');

write(ft,'s');write(ft,'Nr. ');write(ft,'      Nume      ');write(ft,'    Prenume    ');

write(ft,'  Medie I ');write(ft,' Medie II ');write(ft,' Optiune ');write(ft,'  Media');writeln(ft,'s');

write(ft,'Ì');for i:=1 to 71 do write(ft,'Í');writeln(ft,'¹');

      k:=1;i:=1;

      b:=inci^.succ;

      while b<>sfi do

       begin

        if k<17 then

        begin

         x:=b^.inf;

         gotoxy(1,7+k);

         write('s');write(i);

         write(ft,'s');str(i,da);write(ft,da);for j:=1 to (3-length(da)) do write(ft,' ');

         gotoxy(6,7+k);write(x.Nume);gotoxy(23,7+k);write(x.Prenume);

         gotoxy(40,7+k);write(x.Nota1:2:2);gotoxy(51,7+k);write(x.Nota2:2:2);

         gotoxy(58,7+k);write(x.Optiune[1],'/',x.Optiune[2],'/',x.Optiune[3],'/',x.Optiune[4]);

         gotoxy(68,7+k);write(x.Media:5:2);write('s');

         write(ft,x.Nume);for j:=1 to (15-length(x.Nume)) do write(ft,' ');

         write(ft,x.Prenume);for j:=1 to (15-length(x.Prenume)) do write(ft,' ');

         write(ft,'     ',x.Nota1:2:2,'      ');write(ft,x.Nota2:2:2,'    ');

         write(ft,x.Optiune[1],'/',x.Optiune[2],'/',x.Optiune[3],'/',x.Optiune[4]);

         write(ft,'   ',x.Media:5:2);writeln(ft,'s');

         k:=k+1;

        end

        else

        begin

         gotoxy(1,7+k);write('È');for j:=1 to 26 do write('Í');

         write('Apasati spatiu');for j:=41 to 66 do write('Í');

         writeln('¼');

         repeat c:=readkey; until c=' ';

         window(2,8,79,23);clrscr;

         window(1,1,80,25);

         k:=1;

        end;

       b:=b^.succ;

       inc(i);

       end;

       if k<>1 then

        begin

         gotoxy(1,k+7);write('È');for j:=1 to 71 do write('Í');

         writeln('¼');

        end;

        gotoxy(20,23);write('Apasati Spatiu');

        write(ft,'È');for j:=1 to 71 do write(ft,'Í');writeln(ft,'¼');

        close(ft);

        repeat c:=readkey; until c=' ';

end;

procedure adaugare;

begin

clrscr;

gotoxy(7,2);writeln('Baza de date: stud.dat');

  format_ecran;

  repeat

   repeat

    ct:=false;

    valid_nume;

    if x.Nume<>'' then begin

                         valid_prenume;

                         cautare(x.Nume,x.Prenume);

                         if ct then begin

                                      eroare('Studentul deja exista in baza de date',5);

                                      gotoxy(32,5);clreol;

                                      gotoxy(32,6);clreol;

                                    end;

                       end;

   until (not ct) or (x.Nume='');

  if (not ct) and (x.Nume<>'') then

    begin

     valid_nota1;

     valid_nota2; valid_optiune;

     x.Media:=(x.Nota1+x.Nota2)/2;

     b:=sf;

     new(sf);

     b^.inf:=x;

     sf^.pred:=b;

     b^.succ:=sf;

     window(1,1,80,25);

     gotoxy(2,15);

     writeln('Pentru terminare dati Numele vid!');

     window(32,5,80,12);clrscr;

     window(1,1,80,25);

     repeat c:=readkey; until c=' ';

     gotoxy(2,15);clreol;

   end;

  until x.Nume='';

readln;

end;

procedure modificare;

var poz:byte;

begin

clrscr;

    gotoxy(7,2);writeln('Baza de date stud');

    gotoxy(2,3);writeln('Dati numele si prenumele studentului cautat!');

    format_ecran;

    repeat

     valid_nume;

     if x.Nume<>'' then valid_prenume;

     k:=0;

     b:=incb^.succ;

     while (b<>sf) and (k=0) and (x.Nume<>'') do

       begin

        if (x.Nume+x.Prenume)=(b^.inf.Nume+b^.inf.Prenume) then

                             begin

                              k:=1;

                              e:=b;

                             end;

        b:=b^.succ;

       end;

     if (k=0) and (x.Nume<>'') then eroare('Studentul nu este in baza de date!',5);

    until (k=1) or (x.Nume='');

    if k=1 then

              begin

               window(32,5,80,12);clrscr;

               window(1,1,80,25);

               eroare('Introduceti articolul modificat!',5);

               valid_nume;valid_prenume;

               valid_nota1;valid_nota2;

               valid_optiune;x.Media:=(x.Nota1+x.Nota2)/2;

               e^.inf:=x;

              end;

end;

procedure stergere;

var poz:byte;

begin

clrscr;

      gotoxy(1,1);clreol;

      gotoxy(7,2);writeln('Baza de date stud');

      gotoxy(2,3);writeln('Dati numele si prenumele studentului cautat!');

      format_ecran;

      k:=0;

      repeat

      valid_nume;

      if x.Nume<>'' then valid_prenume;

      i:=0;

      if x.Nume<>'' then

                     begin

                      b:=incb^.succ;

                      while (b<>sf) and (k=0) do

                      begin

                       if (x.Nume+x.Prenume)=(b^.inf.Nume+b^.inf.Prenume) then

                                               begin

                                                 k:=1;

                                                 e:=b;

                                               end;

                       b:=b^.succ;

                      end;

                      if k=0 then eroare('Codul nu exista!',5);

                     end;

      until (k=1) or (x.Nume='');

      if x.Nume<>'' then begin

                          gotoxy(2,3);clreol;

                          gotoxy(2,3);writeln('Studentul care va fi sters este:');

                          x:=e^.inf;

                          gotoxy(32,5);writeln(x.Nume);

                          gotoxy(32,6);writeln(x.Prenume);

                          gotoxy(32,7);writeln(x.Nota1:2:2);

                          gotoxy(32,8);writeln(x.Nota2:2:2);

                          gotoxy(32,9);

                          for i:=1 to 3 do

                            write(x.Optiune[i],'/');

                          writeln(x.Optiune[4]);

                          gotoxy(2,15);writeln('Se confirma stergerea (Y/N)?');

                          repeat c:=readkey; until c in ['Y','y','N','n'];

                          if c in ['Y','y'] then

                                   begin

                                     e^.succ^.pred:=e^.pred;

                                     e^.pred^.succ:=e^.succ;

                                     dispose(e);

                                     max:=max-1;

                                   end;

                         end;

end;

begin

clrscr;

      assign(f,'stud.dat');

      reset(f);

      if ioresult<>0 then begin

                           writeln('Baza de date nu exista si nu poate fi incarcata!');

                           repeat c:=readkey; until c=' ';

                          end

                     else

       begin

          new(incb);new(sf);

          incb^.succ:=sf;

          sf^.pred:=incb;

          i:=0;

          while not eof(f) do

           begin

            read(f,x);

            b:=sf;

            new(sf);

            b^.inf:=x;

            sf^.pred:=b;

            b^.succ:=sf;

            inc(i);

           end;

          max:=i-1;

          close(f);

       repeat  

         clrscr;

         is:=false;  

         repeat

          gotoxy(1,1);writeln('1.Crearea unui fisier nou (numai cu fisiere)');

          gotoxy(1,2);writeln('2.Afisare sectie');

          gotoxy(1,3);writeln('3.Actualizare');

          gotoxy(1,4);writeln('4.Terminare');

          c:=readkey;

         until c in ['1','2','3','4'];

         case c of

         '1': begin

              end;

         '2': begin

               repeat

                gotoxy(22,2);writeln('--->  1.Informatica Economica');

                gotoxy(22,3);writeln('      2.Cibernetica');

                gotoxy(22,4);writeln('      3.Statistica economica');

                gotoxy(22,5);writeln('      4.Matematica economica');

                gotoxy(22,6);writeln('      5.Anulare');

                d:=readkey;

               until d in ['1','2','3','4','5'];

               window(22,2,80,10);clrscr;

               window(1,1,80,23);

               case d of

               '1':ordonare(1);

               '2':ordonare(2);

               '3':ordonare(3);

               '4':ordonare(4);

               '5':begin end;

               end;

              end;

         '3': begin

               repeat

                gotoxy(22,3);writeln('--->  1.Adaugare student');

                gotoxy(22,4);writeln('      2.Modificare');

                gotoxy(22,5);writeln('      3.Stergere student');

                gotoxy(22,6);writeln('      4.Anulare');

                d:=readkey;

               until d in ['1','2','3','4'];

               window(22,3,80,8);clrscr;

               window(1,1,80,23);

               case d of

               '1': adaugare;

               '2': modificare;

               '3': stergere;

               '4': begin end;

               end;

              end;

         '4': begin

               assign(f,'stud.dat');

               rewrite(f);

               b:=incb^.succ;

               while b<>sf do

                 begin

                  write(f,b^.inf);

                  b:=b^.succ;

                 end;

               is:=true;

              end;

         end;

       until is;

end;

end.

V. Analiza solutiei

Fiecare metoda a fost compilata si analizata din punctul de vedere al memoriei ocupate si a timpului de executie a procedurii de prelucare a datelor. Acesti timpi au fost obtinuti cu ajutorul utilitarului Turbo Profiler iar datele despre memorie au luate din meniul CompileInformation. Datele sunt redate in urmatoarele tabele.

Memoria ocupata

Metoda Variabilele

Zona de cod (bytes)

Zona de date (bytes)

Numar de linii

Fisiere

18752

1764

609

Vectori

17008

45542

550

Liste

18448

1310

609

Timpii de prelucrare a datelor            

Timpi (sec) Metoda

Fisiere

Vectori

Liste

1.

0,0167

0,0001

0,0001

2.

0,0168

0,0001

0,0001

3.

0,0167

0,0001

0,0001

4.

0,0169

0,0001

0,0001

5.

0,0170

0,0001

0,0001

6.

0,0172

0,0001

0,0001

7.

0,0169

0,0001

0,0001

8.

0,0166

0,0001

0,0001

9.

0,0168

0,0001

0,0001

10.

0,0169

0,0001

0,0001

11.

0,0171

0,0001

0,0001

13.

0,0169

0,0001

0,0001

Media

0,016875

0,0001

0,0001

Din primul tabel se observa ca metoda listelor dublu inlantuite este cea mai avantajoasa. Foloseste o portiune de date mai mica decat celelalte metode. Din punct de vedere al portiunii de cod este pe locul doi dupa metoda vectorilor insa aceasta metoda utilizeaza o portiune de date foarte mare, ceea ce o face de nedorit in cele mai multe cazuri.

Metoda fisierelor este apropiata de metoda listelor dublu inlantuite, atat la  zona de cod cat si la cea de date. Din al doilea tabel insa, se observa ca metoda fisierelor este cea mai lenta la prelucrarea datelor, chiar daca rezultatele sunt insesizabile la o durata atat de mica. La acest capitol celelalte doua metode sunt egale.

Trebuie facuta observatia ca metoda vectorilor si cea a listelor mai au un timp de incarcare a datelor in memorie care nu a fost masurat dar care adunat cu timpul de prelucrare nu poate depasi timpul de prelucrare al primei metode.

Combinand rezultatele celor doua masuratori rezulta ca metoda listelor dublu inlantuite este cea mai eficienta dintre cele folosite.

VI. Concluzii

Solutia pe care am dat-o acestei probleme ofera avantajul unei interfete cu utilizatorul usor de utilizat, unui rezultat care poate fi folosit si dupa terminarea programului prin salvarea sa intr-un fisier text dar si a unei viteze mari si o ocupare minima a memoriei.

Dimensiunea programului este medie, aceasta fiind sacrificata in favoarea unei interfete cat mai bune si o gestionare cat mai buna a introducerii datelor.

Cum a fost mentionat si in cap. III, solutia este foarte utila la impartirea studentilor pe sectii la sfarsitul anului II. Aceste foloseste baza de date existenta sau poate creea una noua daca in directorul curent nu exista una.

Programul poate fi adaptat foarte usor ca un subprogram intr-un program mai mare de gestiune a studentilor sub toate aspectele (burse, transferuri, impartiri pe sectii, programarea examenelor, etc).

VI. Bibliografie

ION IVAN, ROMICA ADAM  ……. “STRUCTURI DE DATE








Politica de confidentialitate

.com Copyright © 2019 - Toate drepturile rezervate.
Toate documentele au caracter informativ cu scop educational.


Proiecte

vezi toate proiectele
 PROIECT DE LECTIE Clasa: I Matematica - Adunarea si scaderea numerelor naturale de la 0 la 30, fara trecere peste ordin
 Proiect didactic Grupa: mijlocie - Consolidarea mersului in echilibru pe o linie trasata pe sol (30 cm)
 Redresor electronic automat pentru incarcarea bateriilor auto - proiect atestat
 Proiectarea instalatiilor de alimentare ale motoarelor cu aprindere prin scanteie cu carburator

Lucrari de diploma

vezi toate lucrarile de diploma
 Lucrare de diploma - eritrodermia psoriazica
 ACTIUNEA DIPLOMATICA A ROMANIEI LA CONFERINTA DE PACE DE LA PARIS (1946-1947)
 Proiect diploma Finante Banci - REALIZAREA INSPECTIEI FISCALE LA O SOCIETATE COMERCIALA
 Lucrare de diploma managementul firmei “diagnosticul si evaluarea firmei”

Lucrari licenta

vezi toate lucrarile de licenta
 CONTABILITATEA FINANCIARA TESTE GRILA LICENTA
 LUCRARE DE LICENTA - FACULTATEA DE EDUCATIE FIZICA SI SPORT
 Lucrare de licenta stiintele naturii siecologie - 'surse de poluare a clisurii dunarii”
 LUCRARE DE LICENTA - Gestiunea stocurilor de materii prime si materiale

Lucrari doctorat

vezi toate lucrarile de doctorat
 Doctorat - Modele dinamice de simulare ale accidentelor rutiere produse intre autovehicul si pieton
 Diagnosticul ecografic in unele afectiuni gastroduodenale si hepatobiliare la animalele de companie - TEZA DE DOCTORAT
 LUCRARE DE DOCTORAT ZOOTEHNIE - AMELIORARE - Estimarea valorii economice a caracterelor din obiectivul ameliorarii intr-o linie materna de porcine

Proiecte de atestat

vezi toate proiectele de atestat
 Proiect atestat informatica- Tehnician operator tehnica de calcul - Unitati de Stocare
 LUCRARE DE ATESTAT ELECTRONIST - TEHNICA DE CALCUL - Placa de baza
 ATESTAT PROFESIONAL LA INFORMATICA - programare FoxPro for Windows
 Proiect atestat tehnician in turism - carnaval la venezia






Termeni si conditii
Contact
Creeaza si tu