Creeaza.com - informatii profesionale despre


Evidentiem nevoile sociale din educatie - Referate profesionale unice



Acasa » referate » informatica
PROIECT ATESTAT MATEMATICA-INFORMATICA - CALUTUL INTELIGENT

PROIECT ATESTAT MATEMATICA-INFORMATICA - CALUTUL INTELIGENT



LICEUL TEORETIC

“TUDOR  VLADIMIRESCU “ -DRAGANESTI -OLT 2009

PROFIL MATEMATICA-INFORMATICA

PROIECT ATESTAT


Tema: “CALUTUL INTELIGENT”

         

Introducere in Turbo Pascal

            Limbajul Pascal a fost elaborat in 1972 de catre Nicklaus Wirth de la Universitatea din Zurich in scopul unei mai bune invatari a programarii. Desi la inceput el a fost cunoscut doar de mediul universitar, apoi el a cunoscut un succes imens.

Structura programelor Pascal

1.         Orice program incepe printr-un cuvint numit PROGRAM care este urmat de numele propriu-zis al programului, adica de un nume ales de utilizator si de semnul ; (punct si virgula)

2.         Orice program contine cel putin odata cuvintele cu un inteles special BEGIN si END

3.         Orice program se termina prin punct

4.         Orice cuvint al programului poate fi scris cu litere mari sau mici, deoarece nu are importanta

5          .In versiunea Turbo, prima linie poate lipsi, desi nu se recomanda acest lucru, din ratiuni de ordine

6.         Plasarea cuvintelor pe linie si numarul de spatii dintre ele sint la alegerea programatorului. Se poate scrie tot programul pe o singura linie, insa este bine ca programul sa fie scris in asa fel incit sa fie usor de inteles.

PREZENTARE APLICATIEI

            Acest program realizat in limbajul de programare Turbo Pascal este un program in care un 'calut' asezat pe o tabla de dimensiuni introduse de la calculator de catre utilizator va pleca dintr-un punct specificat de utilizator si va parcurge fiecare casuta a tablei,nu neaparat intr-o anumita ordine,neparcurzand aceeasi casuta de 2 ori.Acest lucru este posibil datorita unui algoritm care 'gandeste' mutarile calutului.

            Utilizatorul poate alege ca dupa fiecare mutare a calutului acesta sa se opreasca in casuta in care tocmai s-a mutat si continuandu-si mersul dupa ce este apasata orice tasta sau pauza dintre mutari sa fie una scurta mutarea facandu-se automat fara interventia utilizatorului.

            Dimensiunea tablei poate avea valori cuprinse doar in intervalul inchis [5,12].

            In acest program s-au folosit urmatoarele variabile:

type imagine_cal=array[1..30,1..30] of byte;

const cal:imagine_cal=(

(15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,15,15,15,15,15,0 ,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,15,0 ,0 ,15,15,0 ,0 ,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,15,15,0 ,0 ,15,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15),

(15,15,15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15),

(15,15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15),

(15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 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;

    x_pornire,y_pornire:integer;

   

    a:matrice;

    c:sir;

    x1,y1,x2,y2:integer;

    oprire:boolean;

            Functiile si procedurile care s-au folosit in realizarea  acestui program sunt:

procedure initializare_mod_grafic;

var

 grDriver: Integer;

 grMode: Integer;

 ErrCode: Integer;

begin

 grDriver := Detect;

 InitGraph(grDriver, grMode,'bgi');

 

 if Graphresult<>0 then begin

                   writeln('Modul grafic nu a putut fi initializat');

                   halt;

                        end;

end;

procedure cerere_optiuni;    c:char;

var eroare_la_introducerea_datelor:boolean;

begin

    window(1,1,80,25);

    textbackground(black);

    textcolor(white);

    clrscr;

    textbackground(blue);

    window(10,7,70,25);

    write('ÚAAAAAAAA Optiuni posibile pentru problema calului AAAAAAAAAs');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('ÀAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAÙ');

    gotoxy(3,3);

    write('Marimea tablei de sah (maxim 14, minim 5) :');

    gotoxy(3,5);

    write('Punctul din care se va porni (x) :');

    gotoxy(3,6);

    write('Punctul din care se va porni (y) :');

    gotoxy(4,8);

    write('Doriti ca la fiecare mutare programul sa se opreasca');

    gotoxy(4,9);

    write('pana la apasarea unei taste sau sa astepte numai ');

    gotoxy(4,10);

    write('cateva momente si sa continue [ prire/ ontinuare] !');

    textcolor(red);

    gotoxy(35,10);

    write('O');

    gotoxy(42,10);

    write('C');

   

    repeat

       textcolor(white);

       window(60,9,65,9);

       textbackground(black);

       textcolor(white);

       clrscr;

       readln(marime_matrice);

       textbackground(blue);

       clrscr;

       write(marime_matrice);

       if (marime_matrice<15)and(marime_matrice>4) then

                             eroare_la_introducerea_datelor:=false

                                                   else

                             eroare_la_introducerea_datelor:=true;



      

       if IOresult<>0 then eroare_la_introducerea_datelor:=true;

      

    until not eroare_la_introducerea_datelor;

    repeat

       window(50,11,60,11);

       textbackground(black);

       textcolor(white);

       clrscr;

       readln(x_pornire);

       textbackground(blue);

       clrscr;

       write(x_pornire);

       if (x_pornire>0)and(x_pornire<marime_matrice+1) then

                             eroare_la_introducerea_datelor:=false

                                                   else

                             eroare_la_introducerea_datelor:=true;

      

       if IOresult<>0 then eroare_la_introducerea_datelor:=true;

    until not eroare_la_introducerea_datelor;

    repeat

       window(50,12,60,12);

       textbackground(black);

       textcolor(white);

       clrscr;

       readln(y_pornire);

       textbackground(blue);

       clrscr;

       write(y_pornire);

       if (y_pornire>0)and(y_pornire<marime_matrice+1) then

                             eroare_la_introducerea_datelor:=false

                                                   else

                             eroare_la_introducerea_datelor:=true;

      

       if IOresult<>0 then eroare_la_introducerea_datelor:=true;

    until not eroare_la_introducerea_datelor;

    repeat

       window(50,17,60,17);

       textbackground(black);

       textcolor(white);

       clrscr;

       c:=readkey;

       if c in ['O','o','c','C'] then

               eroare_la_introducerea_datelor:=false

                                 else

               eroare_la_introducerea_datelor:=true;

      

       oprire:=c in ['o','O'];

    until not eroare_la_introducerea_datelor;

end;

Aceasta procedura se va opri in momentul in care de la tastura

se vor introduce date valide.

procedure desenare_cal(x,y:integer;c1,c2:byte);

begin

for i:=1 to 30 do

    for j:=1 to 30 do

      if cal[j,i]=15 then putpixel(x+i,y+j,c1)

                     else putpixel(x+i,y+j,c2);

end;

procedure desenare_patrat;

var i,x,y,j:integer;

    s:string;

begin

x1:=(640-(marime_matrice*31))div 2;

y1:=(480-(marime_matrice*31))div 2;

x2:=(640+(marime_matrice*31))div 2;

y2:=(480+(marime_matrice*31))div 2;

line(x1,y1,x1,y2);

line(x1,y1,x2,y1);

line(x2,y2,x1,y2);

line(x2,y2,x2,y1);

i:=1;

x:=x1;

while i<=marime_matrice do begin

      line(x,y1,x,y2);

     

      i:=i+1;

      x:=x+31;

                             end;

i:=1;

y:=y1;

while i<=marime_matrice do begin

      line(x1,y,x2,y);

     

      i:=i+1;

      y:=y+31;

                             end;

end;

Prin desenarea patratului si liniilor verticale cat si orizontale

se va obtine tabla pe care se va deplasa calutul.

function numara_posibilitatile_de_mutare(i,j:integer):integer;

var w:integer;

    nr:integer;

begin

nr:=0;

for w:=1 to 8 do begin

       if (j+yc[w]<=marime_matrice)and(j+yc[w]>0) then

          if (i+xc[w]<=marime_matrice)and(i+xc[w]>0) then

             if a[i+xc[w],j+yc[w]]=0 then inc(nr);

      

                 end;

numara_posibilitatile_de_mutare:=nr;

end;

procedure calculul_efectiv;

var i,j:integer;

    gata:boolean;

    w,q:integer;

    min,poz,singura:integer;

    unde:integer;

    s:string;

begin

gata:=false;

i:=x_pornire;

j:=y_pornire;

unde:=1;

a[i,j]:=unde;

outtextxy(x1+13+(i-1)*31,y1+12+(j-1)*31,'1');

while not gata do begin

      for w:=1 to 8 do begin

       c[w]:=0;

       if (j+yc[w]<=marime_matrice)and(j+yc[w]>0)and

          (i+xc[w]<=marime_matrice)and(i+xc[w]>0) then

         

             if a[i+xc[w],j+yc[w]]=0 then begin

              singura:=w;

              c[w]:=numara_posibilitatile_de_mutare(i+xc[w],j+yc[w]);

                                          end;

                       end;

      min:=8;

      poz:=1;

     

      gata:=true;

      for w:=1 to 8 do

          if (min>c[w])and(c[w]>0) then begin

                      min:=c[w];

                      poz:=w;

                      gata:=false;

                           end;

      if gata then poz:=singura;

      i:=i+xc[poz];

      j:=j+yc[poz];

     

      unde:=unde+1;

      a[i,j]:=unde;

      str(unde,s);

      for q:=1 to 3 do begin

               desenare_cal(x1+(i-1)*31,y1+(j-1)*31,white,black);

               delay(200);

               desenare_cal(x1+(i-1)*31,y1+(j-1)*31,black,white);

               delay(200);

                       end;

      if oprire then  readkey

                else  delay(600);

      desenare_cal(x1+(i-1)*31,y1+(j-1)*31,black,black);

     

      if length(S)=1 then outtextxy(x1+13+(i-1)*31,y1+12+(j-1)*31,s)

                    else

        if length(s)=2 then outtextxy(x1+9+(i-1)*31,y1+12+(j-1)*31,s)

                       else outtextxy(x1+4+(i-1)*31,y1+12+(j-1)*31,s);

                  end;

end;



            Acum urmeaza corpul progamului in care se vor apela functiile

si procedurile create in uramtoarea ordine:

cerere_optiuni;

initializare_mod_grafic;

desenare_patrat;

calculul_efectiv;

.

Codul sursa:

uses graph,crt;

type imagine_cal=array[1..30,1..30] of byte;

const cal:imagine_cal=(

(15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,15,15,15,15,15,0 ,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,15,0 ,0 ,15,15,0 ,0 ,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,15,15,0 ,0 ,15,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15,15),

(15,15,15,15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,15,15),

(15,15,15,15,15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,15,15,15,15,15,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15,15,15,15)

);

type matrice=array[1..20,1..20] of integer;

type coord=array[1..8] of integer;

     sir=array[1..8] of integer;

const xc:coord=(-2,-1, 1, 2, 2, 1,-1,-2);

      yc:coord=( 1, 2, 2, 1,-1,-2,-2,-1);

var i,j:integer;

    marime_matrice:integer;

    x_pornire,y_pornire:integer;

   

    a:matrice;

    c:sir;

    x1,y1,x2,y2:integer;

    oprire:boolean;

procedure initializare_mod_grafic;

var

 grDriver: Integer;

 grMode: Integer;

 ErrCode: Integer;

begin

 grDriver := Detect;

 InitGraph(grDriver, grMode,'bgi');

 

 if Graphresult<>0 then begin

                   writeln('Modul grafic nu a putut fi initializat');

                   halt;

                        end;

end;

procedure cerere_optiuni;

var eroare_la_introducerea_datelor:boolean;

    c:char;

begin

    window(1,1,80,25);

    textbackground(black);

    textcolor(white);

    clrscr;

    textbackground(blue);

    window(10,7,70,25);

    write('ÚAAAAAAAA Optiuni posibile pentru problema calului AAAAAAAAAs');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('³                                                           ³');

    write('ÀAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAÙ');

    gotoxy(3,3);

    write('Marimea tablei de sah (maxim 14, minim 5) :');

    gotoxy(3,5);

    write('Punctul din care se va porni (x) :');

    gotoxy(3,6);

    write('Punctul din care se va porni (y) :');

    gotoxy(4,8);

    write('Doriti ca la fiecare mutare programul sa se opreasca');

    gotoxy(4,9);

    write('pana la apasarea unei taste sau sa astepte numai ');

    gotoxy(4,10);

    write('cateva momente si sa continue [ prire/ ontinuare] !');

    textcolor(red);

    gotoxy(35,10);

    write('O');

    gotoxy(42,10);

    write('C');

   

    repeat

       textcolor(white);

       window(60,9,65,9);

       textbackground(black);

       textcolor(white);

       clrscr;

       readln(marime_matrice);

       textbackground(blue);

       clrscr;

       write(marime_matrice);

       if (marime_matrice<15)and(marime_matrice>4) then

                             eroare_la_introducerea_datelor:=false

                                                   else

                             eroare_la_introducerea_datelor:=true;

      

       if IOresult<>0 then eroare_la_introducerea_datelor:=true;

      

    until not eroare_la_introducerea_datelor;

    repeat

       window(50,11,60,11);

       textbackground(black);

       textcolor(white);

       clrscr;

       readln(x_pornire);

       textbackground(blue);

       clrscr;

       write(x_pornire);

       if (x_pornire>0)and(x_pornire<marime_matrice+1) then

                             eroare_la_introducerea_datelor:=false

                                                   else

                             eroare_la_introducerea_datelor:=true;

      

       if IOresult<>0 then eroare_la_introducerea_datelor:=true;

    until not eroare_la_introducerea_datelor;

    repeat

       window(50,12,60,12);

       textbackground(black);

       textcolor(white);

       clrscr;

       readln(y_pornire);

       textbackground(blue);

       clrscr;

       write(y_pornire);



       if (y_pornire>0)and(y_pornire<marime_matrice+1) then

                             eroare_la_introducerea_datelor:=false

                                                   else

                             eroare_la_introducerea_datelor:=true;

      

       if IOresult<>0 then eroare_la_introducerea_datelor:=true;

    until not eroare_la_introducerea_datelor;

    repeat

       window(50,17,60,17);

       textbackground(black);

       textcolor(white);

       clrscr;

       c:=readkey;

       if c in ['O','o','c','C'] then

               eroare_la_introducerea_datelor:=false

                                 else

               eroare_la_introducerea_datelor:=true;

      

       oprire:=c in ['o','O'];

    until not eroare_la_introducerea_datelor;

end;

procedure desenare_cal(x,y:integer;c1,c2:byte);

begin

for i:=1 to 30 do

    for j:=1 to 30 do

      if cal[j,i]=15 then putpixel(x+i,y+j,c1)

                     else putpixel(x+i,y+j,c2);

end;

procedure desenare_patrat;

var i,x,y,j:integer;

    s:string;

begin

x1:=(640-(marime_matrice*31))div 2;

y1:=(480-(marime_matrice*31))div 2;

x2:=(640+(marime_matrice*31))div 2;

y2:=(480+(marime_matrice*31))div 2;

line(x1,y1,x1,y2);

line(x1,y1,x2,y1);

line(x2,y2,x1,y2);

line(x2,y2,x2,y1);

i:=1;

x:=x1;

while i<=marime_matrice do begin

      line(x,y1,x,y2);

     

      i:=i+1;

      x:=x+31;

                             end;

i:=1;

y:=y1;

while i<=marime_matrice do begin

      line(x1,y,x2,y);

     

      i:=i+1;

      y:=y+31;

                             end;

end;

function numara_posibilitatile_de_mutare(i,j:integer):integer;

var w:integer;

    nr:integer;

begin

nr:=0;

for w:=1 to 8 do begin

       if (j+yc[w]<=marime_matrice)and(j+yc[w]>0) then

          if (i+xc[w]<=marime_matrice)and(i+xc[w]>0) then

             if a[i+xc[w],j+yc[w]]=0 then inc(nr);

      

                 end;

numara_posibilitatile_de_mutare:=nr;

end;

procedure calculul_efectiv;

var i,j:integer;

    gata:boolean;

    w,q:integer;

    min,poz,singura:integer;

    unde:integer;

    s:string;

begin

gata:=false;

i:=x_pornire;

j:=y_pornire;

unde:=1;

a[i,j]:=unde;

outtextxy(x1+13+(i-1)*31,y1+12+(j-1)*31,'1');

while not gata do begin

      for w:=1 to 8 do begin

       c[w]:=0;

       if (j+yc[w]<=marime_matrice)and(j+yc[w]>0)and

          (i+xc[w]<=marime_matrice)and(i+xc[w]>0) then

         

             if a[i+xc[w],j+yc[w]]=0 then begin

              singura:=w;

              c[w]:=numara_posibilitatile_de_mutare(i+xc[w],j+yc[w]);

                                          end;

                       end;

      min:=8;

      poz:=1;

     

      gata:=true;

      for w:=1 to 8 do

          if (min>c[w])and(c[w]>0) then begin

                      min:=c[w];

                      poz:=w;

                      gata:=false;

                           end;

      if gata then poz:=singura;

      i:=i+xc[poz];

      j:=j+yc[poz];

     

      unde:=unde+1;

      a[i,j]:=unde;

      str(unde,s);

      for q:=1 to 3 do begin

               desenare_cal(x1+(i-1)*31,y1+(j-1)*31,white,black);

               delay(200);

               desenare_cal(x1+(i-1)*31,y1+(j-1)*31,black,white);

               delay(200);

                       end;

      if oprire then  readkey

                else  delay(600);

      desenare_cal(x1+(i-1)*31,y1+(j-1)*31,black,black);

     

      if length(S)=1 then outtextxy(x1+13+(i-1)*31,y1+12+(j-1)*31,s)

                    else

        if length(s)=2 then outtextxy(x1+9+(i-1)*31,y1+12+(j-1)*31,s)

                       else outtextxy(x1+4+(i-1)*31,y1+12+(j-1)*31,s);

                  end;

end;

begin

cerere_optiuni;

initializare_mod_grafic;

desenare_patrat;

calculul_efectiv;

if not oprire then readkey;

end.

 

 

 

Bibliografie


1.     L. Toca, A. R. Demco, C. Opincaru, A. Sindile

Informatica – Manual pentru clasa a X-a

Editura Niculescu - Bucuresti, 2000

2.     Fl. Munteanu, T. Ionescu, Gh. Muscǎ, D. Saru, S. M. Dascǎlu

Programarea calculatoarelor – Manual pentru liceele de informatica,

clasele X-XII 

                 Editura Didactica si Pedagogica – Bucuresti, 1995

           

3.     S. Niculescu si colaboratori

Bacalaureat si atestat

                Editura L&S, 1998








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




PROIECT ATESTAT MATEMATICA-INFORMATICA - CALUTUL INTELIGENT
Realizarea functionalitatilor specifice fondului de pensii private obligatorii intr-un sistem web based, urmand a fi implementate pe serverul de la se
ATESTAT LA INFORMATICA - Baza de date relationala aplicata intr-o biblioteca scolara
Functiile unui sistem informational
Proiect informatica - Hidrografia Romaniei
PROIECT DE ATESTAT - AGENITA DE VOIAJ
Monitor 3D multiutilizator cu detectare a pozitiei capului avand laser RGB ca sursa de lumina
Tipul de date abstract sir


Termeni si conditii
Contact
Creeaza si tu