using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
public class CStack
{
private int [] M;
private int [] L;
private const int defaultCapacity = 10;
private int size;
public CStack()
{
this.size = 0;
this.M = new int [defaultCapacity];
this.L = new int[defaultCapacity];
}
public int Max()
{
int ma = this.M[0], id = 0;
for (int i = 1; i < defaultCapacity; ++i)
{
if (ma < this.M[i])
{
ma = this.M[i];
id = i;
}
}
return id;
}
public void Next()
{
int ma = 0, id = Max(), id2 = 0;
for (int i = 0; i < defaultCapacity; ++i)
{
for (int j = 0; j < defaultCapacity; ++j)
{
if (ma < this.M[j] && ma < this.M[id])
{
ma = this.M[j];
id2 = j;
}
}
this.L[id] = id2;
ma = 0;
id = id2;
}
}
public int Pop()
{
return this.M[--this.size];
}
public void Push(int newElement)
{
this.M[this.size++] = newElement;
}
}
static void Main(string[] args)
{
int []input = {9, 7, 11, 10, 5, 0};
CStack M = new CStack();
for (int i = 0; i < 6; ++i)
{
M.Push(input[i]);
}
M.Next();
}
}
}