Advertisement
apl-mhd

Bappy Sir Stack

Mar 22nd, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include "stack.h"
  4.  
  5. using namespace std;
  6.  
  7. int top=0;
  8. int number[100];
  9. int size;
  10.  
  11.  
  12. void stackSize(int Size){
  13.    
  14.     size = Size;
  15.    
  16.    
  17.    
  18. }
  19. void Push(int data){
  20.    
  21.    
  22.    
  23.     if(size == top)
  24.         cout<<"stack overflow"<<endl;
  25.     else
  26.         number[top++] = data;
  27.    
  28.    
  29.        
  30. }
  31.  
  32. void Pop(){
  33.     top -=1;
  34.    
  35.     if(top <0)
  36.         cout<<"underflow";
  37.     else
  38.         number[top] = -1;
  39.          
  40. }
  41. void Print(){
  42.    
  43.     if(top <= 0)
  44.         cout<<"no data";
  45.    
  46.     for(int i=0; i<top; i++){
  47.        
  48.         cout<<number[i]<<" ";
  49.    
  50.     }
  51.    
  52.    
  53.     cout<<endl;
  54.    
  55.    
  56. }
  57.  
  58.  
  59.  
  60. int main(int argc, char **argv)
  61. {
  62.    
  63.  
  64.  
  65.    
  66.    
  67.    
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement