1 / 10

Biblioteca…

Biblioteca…. cerinta…. Se citeste din fisierul Biblioteca(1).in sirul ce contine numarul de pagini ale cartilor (ex: 352, 56, 85, 251, 12, 642, 1250) a)Sa se creeze stiva 1 care sa contina numerele paginilor mai mici decat 200

flo
Download Presentation

Biblioteca…

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Biblioteca…

  2. cerinta… • Se citeste din fisierul Biblioteca(1).in sirul ce contine numarul de pagini ale cartilor (ex: 352, 56, 85, 251, 12, 642, 1250) • a)Sa se creeze stiva 1 care sa contina numerele paginilor mai mici decat 200 • b)Sa se creeze stiva 2 care sa contina numerele paginilor mai mari decat 201 • c)Sa se afiseze stivele. • d)Sa se ordoneze stiva 1 • e)Sa se elimine el minim din stiva 1 • f)Sa se afiseze stiva 1

  3. exemplu… “Biblioteca.in” 352, 56, 85, 251, 12, 642, 1250 “cout<<“ • 56 85 12 • 352 251 642 1250 • 56 85 12 352 251 642 1250 • 12 56 85 • 1256 85 • 56 85

  4. punctul a) (secventa c++)a)Sa se creeze stiva 1 care sa contina numerele paginilor mai mici decat 200 while(f>>x) { if (x<=200) push(varf,x); } void push(nod *&varf,int x) { nod *p; p=new nod; p->pag=x; p->urm=varf; varf=p; } 12 85 56

  5. punctul b) (secventa c++)b)Sa se creeze stiva 2 care sa contina numerele paginilor mai mari decat 201 while(g>>x) { if (x>201) push(varf1,x); } void push(nod *&varf,int x) { nod *p; p=new nod; p->pag=x; p->urm=varf; varf=p; } 1250 642 251 352

  6. punctul c) (secventa c++) c)Sa se afiseze stivele void parcurgere(nod *varf(1)) { nod *p; p=varf(1); while(p) { cout<<" "<<p->pag; p=p->urm; } } 12 85 1250 56 642 251 352

  7. punctul d) (secventa c++)d)Sa se ordoneze stiva 1 void ordonare(nod *varf) { nod *a, *b; int aux; a=varf; while(a){ b=a; while(b){ if(a->pag > b->pag){ aux = a->pag; a->pag = b->pag; b->pag = aux;} b=b->urm; } a=a->urm; } } 12 ok 85 ok interschimbare 56

  8. punctul d) (secventa c++)d)Sa se ordoneze stiva 1 void ordonare(nod *varf) { nod *a, *b; int aux; a=varf; while(a){ b=a; while(b){ if(a->pag > b->pag){ aux = a->pag; a->pag = b->pag; b->pag = aux;} b=b->urm; } a=a->urm; } } 12 ok ok interschimbare 56 85

  9. punctul e) (secventa c++)e)Sa se elimine el minim din stiva 1 void pop(nod *&varf) { nod *p; p=varf; varf=varf->urm; delete p; } 12 56 85

  10. punctul f) (secventa c++)e)Sa se afiseze stiva 1 void parcurgere(nod *varf) { nod *p; p=varf; while(p) { cout<<" "<<p->pag; p=p->urm; } } 56 85

More Related