Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ConsoleApplication14
- {
- public class Node
- {
- public int value;
- public Node Next;
- public Node(int val)
- {
- value = val;
- Next = null;
- }
- }
- public class SingleLL
- {
- public Node Head;
- public Node Tail;
- public SingleLL()
- {
- Head = null;
- Tail = null;
- }
- public void Add(int val)
- {
- Node n = new Node(val);
- if (Head == null)
- {
- Head = n;
- Tail = n;
- }
- else
- {
- Tail.Next = n;
- Tail = Tail.Next;
- }
- }
- public void Print()
- {
- Node cur = Head;
- while (cur != null)
- {
- Console.WriteLine(cur.value);
- cur = cur.Next;
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- SingleLL ss = new SingleLL();
- ss.Add(5);
- ss.Add(10);
- ss.Print();
- Console.Read();
- }
- }
- }
Add Comment
Please, Sign In to add comment