class MyClass
{
static void Main(string[] args)
{
int index = 0;
MyClass pg = new MyClass();
ArrayList al = new ArrayList(30);
for (int i = 0; i < 30; i++)
{
al.Add(i);
}
for (; ; index++)
{
if (al.Count <= 1)
{
break;
}
else if ((index + 1) % 6 == 0)
{
al.RemoveAt(index%al.Count);
pg.Display(al);
}
}
pg.Display(al);//其值即为原ArrayList的索引。
}
public void Display(ArrayList al)
{
foreach (int i in al)
{
Console.Write(i.ToString() + " ");
}
Console.WriteLine();
}