Josephus problem

Users questions: A circle with n individuals, each person's number followed by 1,2,3 ... n. Is from the number of people began to report for the k number of people who report a column m, from a column the next person to re-report the number of people who report it out of the column m, and so on, until all the columns, request that the order of n individuals from the column. with C language algorithms will result in the order form and list two different methods to achieve a single note: This problem is not the so-called Joseph, "enter the password"!
Experts answer: # include stdio.h # include stdlib.h typedefstr uctlist (intdata; structlist * next;) linklist; voidmain intn () (, m, k, i = 1; linklisthead, * p, * q, * l; printf ("ente rn:*n );scanf( %d ,&n);printf( enterm:*n ,&m);scanf( %d ,&m);printf( enterk:*n ,&k);scanf( %d ,&k);l ; ** Create a loop table ** p = l-next; for (i = 1; im; i ++)** find the location of m ** p = p-next; while (p-data! = P-next-data ) (for (i = 1; i k-1; i + +) p = p-next; q = p-next; printf ("% 3d", q-data); p-next = q-next; p = q-next; ** p k +1 points to the first individual Location ** free (q); ** release Space **) printf ("% 3d * n", p-data); free (l); free (p);)
  • This information provided by the users.Thanks!