All pastes #922185 Raw Edit

Mine

public text v1 · immutable
#922185 ·published 2008-02-28 17:00 UTC
rendered paste body
    public static void Org(Stack<int> a)
    {
        Stack<int> result = new Stack<int>();
        while (a.Count != 0)
            result.Push(Max(a));
        while (result.Count != 0)
            a.Push(result.Pop());
    }
    public static int Max(Stack<int> a)
    {
        Stack<int> result = new Stack<int>();
        int max = int.MinValue;
        while (a.Count != 0)
        {
            if (a.Peek() > max)
                max = a.Peek();
            result.Push(a.Pop());
        }
        while (result.Count != 0)
        {
            if (result.Peek() != max)
                a.Push(result.Peek());
            result.Pop();
        }
        return max;
    }