예제 #1
0
        private void display(Node4 head)
        {
            Node4 start = head;

            while (start != null)
            {
                Console.Write(start.data + " ");
                start = start.next;
            }
        }
예제 #2
0
        public void Main()
        {
            Node4 head = null;
            int   T    = Int32.Parse(Console.ReadLine());

            while (T-- > 0)
            {
                int data = Int32.Parse(Console.ReadLine());
                head = insert(head, data);
            }
            display(head);
        }
예제 #3
0
        private Node4 insert(Node4 head, int data)
        {
            Node4 node = new Node4(data);

            if (head == null)
            {
                head = node;
            }
            else
            {
                Node4 nextNode = head;
                while (nextNode.next != null)
                {
                    nextNode = nextNode.next;
                }
                nextNode.next = node;
            }
            return(head);
        }
예제 #4
0
 public Node4(int d)
 {
     data = d;
     next = null;
 }