Beispiel #1
0
    // Driver program to test above methods
    public static void main(String[] args)
    {
        stack s = new stack();

        s.push(10);
        s.push(20);
        System.out.println("Top element :" + s.top());
        s.pop();
        s.push(30);
        s.pop();
        System.out.println("Top element :" + s.top());
    }
    static void Main()
    {
        Console.WriteLine("Enter the string : ");
        stack  s = new stack();
        string check;

        check = Console.ReadLine();
        int size = 0;

        foreach (char c in check)
        {
            s.push(c);
            size++;
        }
        foreach (char c in check)
        {
            // cout<<s.top()<<endl;
            if (c != s.top())
            {
                break;
            }
            s.pop();
            size--;
        }

        if (size > 0)
        {
            Console.WriteLine("This is not Palindrome");
        }
        else
        {
            Console.WriteLine("this is Palindrome");
        }
    }