using System using System Collections Generic using System Linq using

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
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;
}
}
static void Main(string[] args)
{
NewClass List1 = new NewClass();
NewClass List2 = new NewClass();
NewClass ListConcat = new NewClass();
NewClass ListFilter = new NewClass();
NewClass ListP = new NewClass();
int n = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < n; i++)
List1.Add(Convert.ToInt32(Console.ReadLine()));
int m = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < m; i++)
List2.Add(Convert.ToInt32(Console.ReadLine()));
ListConcat = ListConcat.Concat(List1, List2);
ListConcat.WriteList();
ListP.Handlinglist(List1.head);
ListP.WriteList();
string s = Console.ReadLine();
string[] words = s.Split(' ');
int a = Convert.ToInt32(words[1]);
if (words[0] == "<")
List1.Filterless(a).WriteList();
if (words[0] == ">")
List1.Filtermore(a).WriteList();
if (words[0] == "=")
List1.Search().WriteList();
Console.ReadKey();
}
}
}