Ejemplo n.º 1
0
    // For testing. Don't modify.
    public static void Main(string[] args)
    {
        string test = Console.ReadLine();

        if (test == "rpn")
        {
            var rpn = new RPN();
            while (true)
            {
                string userInput = Console.ReadLine();
                if (userInput == "end")
                {
                    break;
                }
                else
                {
                    rpn.Process(userInput);
                    Console.WriteLine("=" + rpn.Result());
                }
            }
        }

        if (test == "remove_max")
        {
            var s1 = new Stack <int>();
            Console.ReadLine()
            .Split(new[] { ',' })
            .Select(Int32.Parse).ToList()
            .ForEach(n => s1.Push(n));

            Console.WriteLine(RemoveMax(ref s1));
            Console.WriteLine(
                string.Join(",", s1.Reverse().Select(i => i.ToString()).ToArray()));
        }
    }
Ejemplo n.º 2
0
    public static void Main()
    {
        var rpn = new RPN();

        while (true)
        {
            Console.Write("RPN>");
            var str = Console.ReadLine();

            rpn.Process(str);

            Console.WriteLine("={0}", rpn.Result);
        }
    }