Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct ellisty
  5. {
  6. int klucz;
  7. ellisty *nast;
  8. };
  9.  
  10. class lista
  11. {
  12. ellisty *glowa;
  13. public:
  14. lista();
  15. ~lista();
  16. bool pusta();
  17. void dodaj(int klucz);
  18. void wyswietl();
  19. };
  20.  
  21. lista::lista()
  22. {
  23. glowa = NULL;
  24. }
  25.  
  26. bool lista::pusta()
  27. {
  28. return (glowa == NULL);
  29. }
  30.  
  31. void lista::dodaj(int klucz)
  32. {
  33. struct ellisty *nowy=new struct ellisty;
  34. nowy->nast = glowa;
  35. nowy->klucz = klucz;
  36. glowa = nowy;
  37. }
  38.  
  39. void lista::wyswietl()
  40. {
  41. struct ellisty *x = glowa;
  42. while (x != NULL)
  43. {
  44. cout << x->klucz << endl;
  45. x = x->nast;
  46. }
  47. }
  48.  
  49. lista::~lista()
  50. {
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement