猴子選大王:一群(M)猴子排成一列
publicintKing(intM
{
//總人數M
intk=
for(inti=
k=(k+N)%i;
return++k;
}
From:http://tw.wingwit.com/Article/program/net/201311/14001.html
猴子選大王:一群(M)猴子排成一列
publicintKing(intM
{
//總人數M
intk=
for(inti=
k=(k+N)%i;
return++k;
}