Module Division
(1) the single-cycle linked list of the leading node abstracts the data type sclinlist, including the basic operation functions: initialize the operation function, insert a node operation function, and delete several node operation functions, take a node data operation function and determine whether the table is a non-empty operation function.
(2) void sclldeleteafter (sclnode * p) is used to delete the next node of the node indicated by p in the single-cycle linked list of the lead node.
(3) void jesephring (sclnode * head, int m), which is a single-cycle linked list head of the leading node,
Use m as the upper limit of the initial report to meet the problem requirements.
(4) void main (), the main function, which provides the test data value, establishes the lead node single-cycle linked list of the test data value, and calls the jesering () function to implement the problem.
# Include <stdio. h>
# Include <stdlib. h>
# Define null 0
// The data type datatype is defined as follows:
Typedef struct
{
Int number;
Int cipher;
} Datatype;
// The struct of the single-cycle linked list node of the leading node is defined as follows:
Typedef struct node
{
Datatype data;
Struct node * next;
} Sclnode;
// Initialization
Void scllinitiate (sclnode ** head)
{If (* head = (sclnode *) malloc (sizeof (sclnode) = null) exit (1 );
(* Head)-> next = * head;
}
// Insert a node
Int scllinsert (sclnode * head, int I, datatype x)
{
Sclnode * p, * q;
Int j;
P = head-> next; j = 1;
While (p! = Head & j <i-1)
{P = p-> next; j ++;
}
If (j! = I-1 & I! = 1)
{Printf ("input parameter error! ");
Return 0;
}
If (q = (sclnode *) malloc (sizeof (sclnode) = null) exit (1 );
Q-> data = x;
Q-> next = p-> next;
P-> next = q;
Return 1;
}
// Delete a node
Int sclldelete (sclnode * head, int I, datatype * x)
{
Sclnode * p, * q;
Int j;
P = head; j = 0;
While (p-> next! = Head & j <i-1)
{P = p-> next; j ++ ;}
If (j! = I-1)
{Printf ("delete parameter error! ");
Return 0;
}
Q = p-> next;
P-> next = p-> next;
* X = q-> data;
Free (q );
Return 1;
}
// Obtain the element value of a node data
Int scllget (sclnode * head, int I, datatype * x)
{
Sclnode * p;
Int j;
P = head; j = 0;
& N
<