Game Description :

30 One person in a boat , overload , need 15 People disembark .

So people lined up , The position of the queue is their number .

number off , from 1 start , Count to 9 People disembark .

So cycle , Until there's only one left on the ship 15 Until people , Ask which number of people got off the ship ?

#include<stdio.h> #include<stdlib.h> struct shipper { int num; struct shipper*
p_num; }; typedef struct shipper Shipper; int main() { int i; int count;
count=0; Shipper* ship_temp; Shipper* ship_head; Shipper* ship_ele; ship_temp =
(Shipper *)malloc(sizeof(Shipper)); ship_head=ship_temp; for(i=1;i<=30;i++) {
ship_ele = (Shipper *)malloc(sizeof(Shipper)); //malloc ship_ele->num=i;
ship_temp->p_num=ship_ele; //temp First as the head node , then temp Point to the next node ship_temp=ship_ele; }
/*********** Link the beginning and end of the list **********/ ship_temp->p_num=ship_head->p_num;
/*********** Verify the circular linked list **********/ while(0) { printf("%d\n",ship_head->p_num->num) ;
ship_head->p_num=ship_head->p_num->p_num; } ship_temp=ship_head->p_num;
while(count<=14) { count=count+1; for(i=1;i<=7;i++) {
ship_temp=ship_temp->p_num; if(i==7) {
printf(" The disembarkation personnel number is :%d\n",ship_temp->p_num->num);
ship_temp->p_num=ship_temp->p_num->p_num; } } ship_temp=ship_temp->p_num; } }

Technology
©2019-2020 Toolsou All rights reserved,
Solve in servlet The Chinese output in is a question mark C String function and character function in language MySQL management 35 A small coup optimization Java performance —— Concise article Seven sorting algorithms (java code ) use Ansible Batch deployment SSH Password free login to remote host according to excel generate create Build table SQL sentence Spring Source code series ( sixteen )Spring merge BeanDefinition Principle of Virtual machine installation Linux course What are the common exception classes ?