Joseph Algorithm

xiaoxiao2021-03-06  37

#include

#define iMax (10000)

// Joseph Algorithm void main () {Int Inumberofprisoners; // Prisoner Total Int Inumberoff; // 号 号 号 号 号 号 PRINTF ("Please enter the total number of prisoners"); scanf ("%) D ", & inumberofprisoners); Printf (" Please enter the number of quotes "); Scanf ("% d ", & inumberoff); Printf (" Please enter from the first few people "); Scanf ("% D ", & iStart) ; // Establish a prisoner array, and assign the value INT iPrisoner [IMAX]; for (int J = 0; j iprisoner inumberofprisoners-1) // If p exceeding the range of array addresses, put the P = iPrisoner;} if (* p! = 0) {IF (iLoOP == Inumberoff) // If the value of the loop number is equal to the number of points, the value of the polar points to 0 {* p = 0;} iLoop ;} P ;}} P = iprisoner; while (* p == 0) {P ;} printf ("% D is the last remaining in the case ./n", inumberofprisoners, *p);

转载请注明原文地址:https://www.9cbs.com/read-81817.html

New Post(0)