1, 2 ,..., n of the n people sit at the Round Table clockwise. Each person holds a password (positive integer), starts reporting the number of s people, reports the number to the m people, and reports the number from the next person, until all members are listed
Below is the C language source program compiled using the array method! For your reference only. Please give me more valuable comments!
# Include <stdio. h>
Main ()
{
Int n, s, password;
Int a [100];
Int I, j, counter1 = 1, counter2 = 0;
Printf ("please input the value of n :");
Scanf ("% d", & n );
Printf ("please input the number of the biginer :");
Scanf ("% d", & s );
If (s> n)
{
Printf ("please reinput the number less than % d:", n );
Scanf ("% d", & s );
}
Printf ("please input the value of the password :");
Scanf ("% d", & password );
For (I = 0; I <n; I ++)
A [I] = I + 1;
J = s-1;
While (counter2! = N)
{
While (password = 1)
{
Printf ("% 4d", a [j]);
Counter2 ++;
If (counter2 = n)
Return;
If (j <n-1)
J ++;
Else
J = 0;
}
While (password! = 1 & counter1! = Password)
{
If (j <n-1)
J ++;
Else
J = 0;
While (a [j] = 0)
{
If (j <n-1)
J ++;
Else
J = 0;
}
Counter1 ++;
If (counter1 = password)
{
Printf ("% 4d", a [j]);
A [j] = 0;
If (j <n-1)
J ++;
Else
& Nb