sd_4
.pdf11
return null;
}
Node n = first; while (n != null)
{
Console.WriteLine(n.data); n = n.next;
}
return true;
}
public bool AddOchered(int data)
{
if (first == null)
{
first = last = new Node(data, null); Z++;
return true;
}
else
{
Node node = new Node(data, null); last.next = node;
last = node; Z++; return true;
}
}
public int RemoveElementOcheredi(int number)
{
if (first == null)
{
Console.WriteLine("\nОчередь пустует\n"); return default;
}
Node n = first; number = n.data; first = first.next; Z--;
return number;
}
public int PoiskPervogo(int index)
{
if (first == null)
{
Console.WriteLine("Очередь пустует"); return default;
}
12
Node n = first; return n.data;
}
}
static void RemoveElementa(Stack<int> stack, int index)
{
Stack<int> temp = new Stack<int>();
for (int i = 0, count = stack.Count - index - 1; i < count; i++)
{
temp.Push(stack.Pop());
}
stack.Pop();
while (temp.Count != 0)
{
stack.Push(temp.Pop());
}
}
class Node
{
public int data; public Node next; public Node before;
public Node(int Data, Node Next = null, Node Before = null)
{
next = Next; before = Before; data = Data;
}
}
}
}