Advertisement
haquaa

Untitled

Jan 4th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Stack
  7. {
  8.     class Stack
  9.     {
  10.         Node start = null;
  11.  
  12.         public void push(int val)
  13.         {
  14.             Node tmp = new Node(val);
  15.             tmp.next = start;
  16.             start = tmp;
  17.         }
  18.  
  19.         public void pop()
  20.         {
  21.             if (start == null)
  22.             {
  23.                 return;
  24.             }
  25.  
  26.             start = start.next;
  27.         }
  28.  
  29.         public int top()
  30.         {
  31.             if (start == null)
  32.             {
  33.                 return 0;
  34.             }
  35.  
  36.             return start.info;
  37.         }
  38.  
  39.  
  40.         public bool empty()
  41.         {
  42.             return (start == null);
  43.         }
  44.  
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement