//извлечь из стека public int Pop() { NodeSt p = Head; Head = Head.next; return(p.state); }
//добавить в стек public void Push(int x) { if (Head == null) { NodeSt p = new NodeSt(); p.state = x; p.next = Head; Head = p; } else { NodeSt p = new NodeSt(); p.state = x; p.number = Head.number + 1; p.next = Head; Head = p; } }
public void PushIndex(int index, int token) { NodeSt temp = Dostup; bool flag = false; while (!flag && temp != null) { if (temp.number == index) { flag = true; } else { temp = temp.next; } } if (flag) { temp.state = token; } }
public Stack() { Head = null; }
public NodeSt() { state = 0; number = 0; next = null; }