public class NewClass
{
public class Node
{
public int value;
public Node next;
public Node (int value, Node next)
{
this.value = value;
this.next = next;
}
}
public Node head, tail;
public void WriteList()
{
for (Node i = head; i != null; i = i.next)
Console.Write("{0} ", i.value);
Console.WriteLine();
}
public int quantity = 0;
public void Add(int value)
{
if (head == null)
{
head = new Node(value, null);
tail = head;
}
else
{
tail.next = new Node(value, null);
tail = tail.next;
}
quantity++;
}
public NewClass Filterless(int n)
{
Node ListElement = this.head;
NewClass List = new NewClass();
while (ListElement.next != null)
{
if (ListElement.value < n)
List.Add(ListElement.value);
ListElement = ListElement.next;
}
if (ListElement.value < n) List.Add(ListElement.value);
return (List);
}
public NewClass Filtermore(int n)
{
Node ListElement = this.head;
NewClass List = new NewClass();
while (ListElement.next != null)
{
if (ListElement.value > n)
List.Add(ListElement.value);
ListElement = ListElement.next;
}
if (ListElement.value > n) List.Add(ListElement.value);
return (List);
}
public NewClass Search()
{
Node ListElement = this.head;
NewClass List = new NewClass();
while (ListElement.next != null)
{
if (ListElement.value == 0 && List.quantity == 0)
List.Add(ListElement.value);
ListElement = ListElement.next;
}
if (ListElement.value < 0) List.Add(ListElement.value);
return (List);
}
public void Handlinglist (Node i)
{
if (i.next != null)
Handlinglist(i.next);
this.Add(i.value);
}
public NewClass Concat(NewClass List1, NewClass List2)
{
NewClass List3 = new NewClass();
Node ListElement = List1.head;
while (ListElement != null)
{
List3.Add(ListElement.value);
ListElement = ListElement.next;
}
ListElement = List2.head;
while (ListElement != null)
{
List3.Add(ListElement.value);
ListElement = ListElement.next;
}
return List3;
}
}