public static void Main(string[] args) { SetOfStacks obj = new SetOfStacks(5); obj.Push(1); obj.Push(2); obj.Push(3); obj.Push(4); obj.Push(5); obj.Push(6); obj.Push(7); obj.Push(8); obj.Pop(); obj.Push(8); obj.Push(9); obj.Push(10); obj.Push(11); obj.Pop(); obj.Push(11); obj.Push(12); obj.Push(13); obj.PopAt(0); obj.PopAt(2); obj.PopAt(1); obj.PopAt(1); }
static void Main(string[] args) { Console.Write("1- push element; "); Console.Write("2 - pop element; "); Console.Write("3 - popAt element by index; "); Console.Write("4 - peek; "); Console.Write("0 - break; "); int element = 0; int number = 0; SetOfStacks setOfStacks = new SetOfStacks(); setOfStacks = new SetOfStacks(); do { Console.WriteLine(); number = HelpersForSet.ReadInt("what you choose? - "); if (number == 1) { while (true) { element = HelpersForSet.ReadInt(" "); if (element == 0) { break; } else { int lengthOfLastStack = setOfStacks.GetLengthLastStack(setOfStacks); if (lengthOfLastStack == 4) { Console.WriteLine(); setOfStacks.Push(element); } else { setOfStacks.Push(element); } } } } else if (number == 2) { element = setOfStacks.Pop(); Console.WriteLine($"pop = {element}"); } else if (number == 3) { int index = HelpersForSet.ReadInt("index = "); element = setOfStacks.PopAt(index); Console.WriteLine($"pop by stack index {index} = {element}"); } else if (number == 4) { element = setOfStacks.Peek(); Console.WriteLine($"peek = {element}"); } else { break; } }while (number != 0); Console.ReadKey(); }