Facebook
From Wet Dolphin, 4 Years ago, written in C++.
This paste is a reply to Re: Re: Re: Untitled from Torrid Flamingo - view diff
Embed
Download Paste or View Raw
Hits: 319
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. struct element {
  9.     int liczba = 0;
  10.     element *next = nullptr;
  11. };
  12.  
  13. bool czyPusty(element *stos) {
  14.     bool wynik = stos == nullptr ? true : false;
  15.     return wynik;
  16. }
  17.  
  18. void dodajElement(element *&stos, int wartosc) {
  19.     element *el = new element;
  20.     el->liczba = wartosc;
  21.     el->next = stos;
  22.     stos = el;
  23.  
  24. }
  25.  
  26. void usunElement(element *&stos) {
  27.     if (stos != nullptr) {
  28.         element *temp = stos;
  29.         stos = stos->next;
  30.         delete temp;
  31.     } else {
  32.         cout << "Stos jesy juz pusty" << endl;
  33.     }
  34. }
  35.  
  36. int pobierzElement(element *stos) {
  37.     if (stos != nullptr) {
  38.         return stos->liczba;
  39.     } else {
  40.         cout << "Stos jest pusty" << endl;
  41.     };
  42. }
  43.