Example #1
0
        public static bool IsPalindrome(string word)
        {
            StackMy <string> stackMy = new StackMy <string>();

            for (int i = 0; i < word.Length; i++)
            {
                stackMy.Push(word.Substring(i, 1));
            }

            for (int i = 0; i < word.Length; i++)
            {
                if (word.Substring(i, 1) != stackMy.Pop())
                {
                    return(false);
                }
            }
            return(true);
        }
Example #2
0
        public static string ConvertPositiveIntegerFromDecimalToOtherForms(int num, int form)
        {
            StackMy <int> tempData = new StackMy <int>();

            if (num == 0)
            {
                return(0.ToString());
            }

            while (num != 0)
            {
                tempData.Push(num % form);
                num = num / form;
            }

            string temp = null;

            while (tempData.Count > 0)
            {
                temp += tempData.Pop() + " ";
            }
            return(temp);
        }
Example #3
0
        public static int Calculate(string expression)
        {
            StackMy <string> stackNums     = new StackMy <string>();
            StackMy <string> stackOps      = new StackMy <string>();
            StackMy <string> stackNumsTemp = new StackMy <string>();
            StackMy <string> stackOpsTemp  = new StackMy <string>();

            for (int i = 0; i < expression.Length; i++)
            {
                string temp = expression.Substring(i, 1);
                if (IsNumberic(temp))
                {
                    stackNums.Push(temp);
                }
                else
                {
                    stackOps.Push(temp);
                }
            }



            return(-1);
        }