Advertisement
apl-mhd

Huda Sir quoue Linkedlist

Apr 2nd, 2017
131
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 <cstdio>
  3. using namespace std;
  4.  
  5. struct quoueFrame{
  6.    
  7.     int data;
  8.     struct quoueFrame *next;
  9.    
  10.     };
  11.    
  12. typedef struct quoueFrame node;
  13.  
  14.     node *top,*f,*r;
  15.    
  16.        
  17. void Push(int x){
  18.    
  19.     node *temp;
  20.     temp=new node();
  21.     temp->data=x;
  22.     r->next= temp;
  23.     r= temp;
  24.     r->next = NULL;
  25. }
  26.  
  27. void Print(){
  28.    
  29.     node *temp;
  30.     temp =f->next;
  31.    
  32.     while(temp !=NULL){
  33.        
  34.         cout<<temp->data<<" ";
  35.         temp=temp->next;
  36.     }
  37.    
  38.     cout<<endl;
  39.  
  40.    
  41. }
  42.  
  43. void Pop(){
  44.     node *temp;
  45.     if(f==r)
  46.         cout<<"underflow"<<endl;
  47.     else{
  48.        
  49.     temp = f->next;
  50.     f->next= temp->next;
  51.     delete temp;
  52.     if(f->next == NULL)
  53.         r = f;
  54. }
  55. }
  56.  
  57.  void Top(){
  58.    
  59.  
  60.    
  61. }
  62.  
  63.  
  64. int main(int argc, char **argv)
  65. {
  66.     top = new node();
  67.     r = top;
  68.     f  = top ;
  69.    
  70.    
  71.     Push(10);
  72.     Push(20);
  73.     Push(30);
  74.     Pop();
  75.     Pop();
  76.     Pop();
  77.     Pop();
  78.    
  79.  
  80.    
  81.    
  82.    
  83.    
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement