Joseph problem

xiaoxiao2021-03-05  29

#include

#define M 8

Void Josephus ()

{

INT I, J, S, A [M], N;

Printf ("please input n =");

Scanf ("% d", & n);

For (i = 0; i

A [i] = 1;

J = 0;

For (i = 0; i

{

S = 0;

While (s

{

IF (j

J = J 1;

Else

J = 0;

S = S a [J];

}

IF (j! = 0)

Printf ("% 3D / N", J);

Else

Printf ("% 3D / N", M);

a [j] = 0;

}

}

void main ()

{

Josephus ();

}

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

New Post(0)