有一千个人,开始报数,按1,2,3 报数,报1的人被舍弃,问最后留下的是原来一千人中的哪一位(一千个人是首位相接围成一个圈,每一轮都不是从头开始的)大家说说思路了,要个比较简单的方法
解决方案 »
- UpdatePanel中点击按钮不弹出对话框问题
- Dev-gridControl存在多级列表时如何获取子列表选中行某一个字段的值?
- C#如何获得引用类型在内存中的地址
- 怎么做类似ms visio一样的画流程图的东西?,
- 该服务器不可操作,此问题是什么原因导致
- .net自己带的那种安装工具生成怎么让他在开始菜单下生成快接方式
- freeTextBox将设计模式转为html模式再转会来,原来的相对路径地址变成绝对了,则么解决
- 高分求.Net2003工自带的混淆器注册码或者其他可用于混淆.net项目源代码的工具
- 请教一个继承类的判断问题。
- vs.net ide(C#)下开发web form,web form之间是否可设继承关系?
- VS的问题
- 路径编码的的问题
{
public int realindex;
public int currentindex;
}private void getperson()
{
int TotalPerosons = 1000;
ArrayList persons = new ArrayList();
for (int i = 0; i < TotalPerosons; i++)
{
person oneperson = new person();
oneperson.realindex = i;
oneperson.currentindex = i;
persons.Add(oneperson);
} while (persons.Count > 1)
{
for (int i = 0; i < persons.Count; i++)
{
person cuperson = (person)persons[i];
if (cuperson.currentindex % 3 == 0)
{
persons.Remove(cuperson);
}
} for (int j = 0; j < persons.Count; j++)
{
person cuperson = (person)persons[j];
cuperson.currentindex = j;
persons[j] = cuperson;
}
}
person Lastperson = (person)persons[0];
MessageBox.Show(Lastperson.realindex.ToString());
}