Home > Back-end >  Look at all the problem solving method
Look at all the problem solving method

Time:01-26

CodePudding user response:

reference 1st floor forever74 response:
it is no wonder that the university entrance exam language always valued, originally some suggestion is all not good expression,
What code is written out all the people, scattered, all off, do not have what good-looking of,


Adversary, challenging, and it should tell loser and winner, and that makes sense,,,

CodePudding user response:

Isn't this Joseph ring? 90% is the same, different places is the count value is changing,
Write a Joseph ring code first, then consider the count value change to go well,

CodePudding user response:

# include
# include

Typedef struct Node
{
The int data;
Struct Node * next;
} the node;
Typedef struct Node * LinkList;

/*===============================================================
CreateLinkList function function:
Create list L, and will be given an array a, as well as the number of elements in an array of n, the tail insertion method to establish circular linked list
===================================================================*/
LinkList createlist (LinkList * L, int n, int a [])
{
LinkList p, r;
int i;

(* L)=(LinkList) malloc (sizeof (node));//set up head node
R=* L;

for(i=0; I{
P=(LinkList) malloc (sizeof (node));//generated new node
P - & gt; data=https://bbs.csdn.net/topics/a [I];
R - & gt; Next=p;
R=p;
}
R - & gt; Next=(* L) - & gt; Next;
Free (* L);
Return r - & gt; Next;
}

Int main ()
{
Int A []={0};
Int I, j, N, m;
LinkList PI, p, temp;

Printf (" please enter the number of list elements: ");
The scanf (" % d ", & amp; N);
for(i=0; I{
The scanf (" % d ", & amp; A [I]);
}
P=createlist (& amp; PI, N, A);
M=p - & gt; The data;
While (p!=p - & gt; Next)
{
For (j=1; J<(m - 1); J++)
{
P=p - & gt; Next;
}
M=p - & gt; Next - & gt; The data;
Printf (" % d - & gt;" , m);
Temp=p - & gt; Next;
P - & gt; Next=temp - & gt; Next;
Free (temp);
P=p - & gt; Next;
}
Printf (" % d \ n ", p - & gt; The data);

return 0;
}
  • Related