Ejemplo n.º 1
0
        public static bool checkPalindrom(String s)
        {
            String    firstRead  = s;
            String    secondRead = "";
            stackChar stack      = new stackChar(s.Length);

            for (int i = 0; i < s.Length; i++)
            {
                stack.Push(s[i]);
            }

            for (int j = 0; j < s.Length; j++)
            {
                secondRead += stack.Top(); stack.Pop();
            }

            if (firstRead.Equals(secondRead, StringComparison.CurrentCultureIgnoreCase))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public static String reverseString(String s)
        {
            String    result = "";
            stackChar stack  = new stackChar(s.Length);

            for (int i = 0; i < s.Length; i++)
            {
                stack.Push(s[i]);
            }

            for (int j = 0; j < s.Length; j++)
            {
                result += stack.Top(); stack.Pop();
            }

            return(result);
        }