Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- /*Napisaæ program, który bêdzie implementowa³ stos przy pomocy kontenera list. W
- szczególnoœci chodzi o umo¿liwienie wykonywanie takich operacji jak umieszczanie
- elementu na stosie, zdejmowanie elementu ze stosu, wyœwietlanie zawartoœci stosu, przy
- u¿yciu prostego menu.*/
- using namespace std;
- int main()
- {
- int wybor, liczba;
- list <int> lista;
- cout << "\n1. Dodaj na stos.\n2. Usun ze stosu.\n3.Wyswietl."<<endl;
- cin >> wybor;
- switch(wybor)
- {
- case 1:
- cout << "Wpisz liczbe: ";
- cin >> liczba;
- lista.push_front(liczba);
- break;
- case 2:
- lista.pop_front();
- break;
- case 3:
- list<int>::iterator it;
- for( it=lista.begin(); it!=lista.end(); ++it )
- {
- cout<< *it <<'\n';
- }
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement