Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5.  
  6. struct list{
  7. int value;
  8. list *next;
  9. list *prev;
  10. }
  11.  
  12. void step(list *p)
  13. {
  14. if(p){
  15.  
  16. while (p)
  17. {
  18. cout<<p;
  19. p=p->next;
  20. }}
  21.  
  22. else {cout<<"Kolejka jest pusta";
  23. }
  24.  
  25. }
  26.  
  27. void push (list *tail, list *p, int x)
  28. {
  29. p=new list; //robimy miejsce w pamieci
  30. p->value=x; //przypisujemy na to miejsce x;
  31. p->prev=tail;
  32. tail=p;
  33. }
  34.  
  35. void pop (list *head, list *p)
  36. {
  37. p=head;
  38. if(p)
  39. {
  40. head=p->next;
  41. }
  42. else {
  43. cout <<"Kolejka jest pusta";
  44. }
  45. delete p;
  46. }
  47.  
  48. int main() {
  49. list *d=NULL;
  50. list *t=NULL;
  51. list *b=NULL;
  52.  
  53. int choice;
  54. cout<<"Instukcja do kolejki"<<endl;
  55. cout <<"wpisz 1- dodaj element"<<endl;
  56. //dalsze 2 i 3 z case'a
  57. cout <<"wpisz 0- opuszczenie"<<endl;
  58.  
  59. while (cin>>choice){
  60.  
  61. swich (choice)
  62. {
  63. case 1: push(t,d, cin>>y);
  64. case 2: pop(b,d);
  65. case 3: step(d);
  66. }}
  67. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement