Xian: (1) all the monkeys into a circle, numbered respectively: 1, 2,... Count, "1" from the beginning to count, to "5" to exit outside, the last one; According to the serial number of the original and then all the monkeys into a big circle, starting from the "1" to count, count to "8" to exit outside, then the rest one,
(2) chan: after a battle of wits left two people in them, his fists, a winner is king,
A thin monkey came late, looking around for a week, to find a place to stand down. In the battle of wits two number off, finally left is his, he is the Monkey King,
Excuse me, how many monkeys are: (1) the mountain of the communist party of China? (2) thin monkey standing position number is how many?
CodePudding user response:
Fyi:# include & lt; stdio.h>
Int game (int * p, int n, int m)
{
Int I, c, t;
C=t=0;
for(i=0; i
i=0;
While (t & lt; N - 1)
{
If (p [I]) c + +;
If (c==m)
{
P [I]=0;
t++;
C=0;
}
I=(I + 1) % n;
}
for(i=0; i{
If (p [I]) break;
}
The return p [I];
}
Int main (void)
{
int n;
Int arr [100].
For (n=2; N & lt;=100; N++)
{
If (game (arr, n, 5)==game (arr, n, 8))
{
Printf (" Monkey Count: % d \ \ t t ", n);
Printf (" Winner ID: \ n \ t % d ", the game (arr, n, 5));
}
}
return 0;
}