Joseph PHY problem Overview: Assume that N people are sitting around the Round Table, report data from S people, report data to M columns, and then count the report from the next person, when the number is M, the columns are displayed. Each person's information must be output sequentially in the column!
# Include <stdio. h>
# Include <stdlib. h>
Typedef int datatype;
Typedef struct cnode
{
Datatype data;
Struct cnode * next;
} Clistnode;
Typedef clistnode * clinklist;
Clinklist head;
Void Joseph (int n, int m, int s)
{
Int I, j;
Clinklist creatclinklist (int );
Clistnode * p, * q, * r, * t;
Head = creatclinklist (n );
Q = head;
If (s> n) printf ("error! N ");
For (I = 1; I <s; I ++)
Q = q-> next;
P = q-> next;
For (I = 1; I <= n; I ++)
{
J = 1;
While (j <m)
{
R = p;
P = p-> next;
If (p = head)
Continue;
J ++;
}
Printf ("% 4d", p-> data );
T = p;
If (p-> next = head)
{
P = p-> next;
R-> next = head;
}
Else
{
P = p-> next;
R-> next = p;
}
Free (t );
}
}
Clinklist creatclinklist (int n)
{
Int I;
Clinklist p;
P = (clinklist) malloc (sizeof (clistnode ));
P-> next = NULL;
Head = p;
Printf ("Please input the element records of the chain! N ");
For (I = n; I> 0; I --)
{P = (clinklist) malloc (sizeof (clistnode ));
Scanf ("% d", & p-> data );
If (n = I)
{
P-> next = head;
Head-> next = p;
}
Else
{
P-> next = head-> next
<