Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. /*Napisaæ program, który bêdzie implementowa³ stos przy pomocy kontenera list. W
  4. szczególnoœci chodzi o umo¿liwienie wykonywanie takich operacji jak umieszczanie
  5. elementu na stosie, zdejmowanie elementu ze stosu, wyœwietlanie zawartoœci stosu, przy
  6. u¿yciu prostego menu.*/
  7. using namespace std;
  8.  
  9.  
  10. int main()
  11. {
  12.     int wybor, liczba;
  13.     list <int> lista;
  14.     cout << "\n1. Dodaj na stos.\n2. Usun ze stosu.\n3.Wyswietl."<<endl;
  15.     cin >> wybor;
  16.     switch(wybor)
  17.     {
  18.     case 1:
  19.         cout << "Wpisz liczbe: ";
  20.         cin >> liczba;
  21.         lista.push_front(liczba);
  22.         break;
  23.  
  24.     case 2:
  25.         lista.pop_front();
  26.         break;
  27.  
  28.     case 3:
  29.      list<int>::iterator it;
  30.     for( it=lista.begin(); it!=lista.end(); ++it )
  31.     {
  32.     cout<< *it <<'\n';
  33.     }
  34.     break;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement