using System.Collections.Generic;
static double CalculateReversePolishNotation(string str)
var stack = new Stack<double>();
foreach(string operand in str.Split())
a = stack.Pop(); b = stack.Pop();
a = stack.Pop(); b = stack.Pop();
a = stack.Pop(); b = stack.Pop();
a = stack.Pop(); b = stack.Pop();
double.TryParse(operand, out val);
public static void Main()
Console.WriteLine("UniLecs");
Console.WriteLine(string.Format("Answer = {0}", CalculateReversePolishNotation("7 2 3 * -")));
Console.WriteLine(string.Format("Answer = {0}", CalculateReversePolishNotation("10 15 - 3 *")));
Console.WriteLine(string.Format("Answer = {0}", CalculateReversePolishNotation("3 10 15 - *")));
Console.WriteLine(string.Format("Answer = {0}", CalculateReversePolishNotation("8 2 5 * + 1 2 3 * + 4 - /")));