There are n individuals in a circle, order automatic arranging. Starting from the first person (from 1 to 3 count off), where 3 of the people out of the circle, ask the last left is the original number of places
/******************************************************e8.5plan: Can not cycle shout 1 to 3, Replace the Create----------------------------with the sum of multiples of 3 by: idooi liutime: 2015/10/15-1500----------------------------------******************************************************/ #include <stdio.h> #include <stdlib.h>int expthree (int n, int Manarray[]); Int main (void) { int nman; //how many people char *pman; //the array int sitelast; //the last person ' S site int i; printf ("please input how many People:\n "); &NBSP;&NBSP;&NBSP;&NBSP;SCANF ("%d ", &nman); pman=malloc (nMan* sizeof (char)); &NBSP;&NBSP;&NBSP;&NBSP;//ASSIGNMENT&NBSP;&NBSP;&NBSp; for (i=0; i<nman; i++) * (pMan+i) = ' Y '; sitelast=expthree (Nman, pman); printf ("The last One\ ' s site is %d\n ", sitelast); free (PMan); return 0;} Int expthree (int n, int manarray[]) { int i, j; int sitelast; //the last person ' s site int flag=0; //Count off int k; for (i=0; i<n; i++) { k=0; //for check how many people last for (j=0; j<n; j++) { if (manArray[j ]== ' Y ') k++; siteLast=j; } if (k==1) //Only one person break; if (manarray[i]== ' Y ') { flag++; //The person who in the team take the next number //if the Person ' S&NBSP;NUMBER&NBSP;IS&NBsp;divisible by 3, take out of the team if (flag%3==0) manarray[i]= ' N '; } } return sitelast;}
In a lap number 3 exit last person location question--c Language Rectification Edition Exercise 8.5