/*
Summary: is to create a circular single-linked list, and then the loop to delete the node:
Note: 1. When the pointer variable s is not allocated dynamic memory, it is equal to another pointer that allocates memory (q) equivalent to
Point S to its memory and cannot establish a link.
2. This linked list lead node
Problems encountered: 1. In the selection of people encountered obstacles (do not know how to choose)
2. Set head node, loop (difficulty)
* * #include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
static int count;
typedef struct NODE
{
int num;
struct node *next;
}lnode,*linklist;
Linklist creat (linklist l,int N)
{
Linklist p,s,q;
int i; Count=n;
p= (linklist) malloc (sizeof (Lnode));
p->next=null;
l->next=p;
p->num=1;
S=p;
for (i=2;i<=n;i++)
{
Q= (linklist) malloc (sizeof (Lnode));
q->num=i;
s->next=q;
s=q;
}
s->next=l->next;
return l;
}
void Select (Linklist l,int m)
{
Linklist p,q,s;
int i,j,t=0;
P=l;
for (i=0;i<count;i++)//output eight values
{
for (j=1;j<m;j++)//Pointer right shift
{
p=p->next;
}
q=p->next;
printf ("%d", q->num);
p->next=q->next;//Note that the difference between assignment and link is related to next;
Free (q);//Note: After deleting node 1, start from node 5;
}
}
int main ()
{
Linklist l,s;
L= (linklist) malloc (sizeof (Lnode));
int n,m;
printf ("Please enter the number of n:\n");
scanf ("%d", &n);
Creat (L,n);
printf ("Number to figure is m:\n");
scanf ("%d", &m);
Select (L,m);
return 0;
}
Joseph Ring Problem (lead node)