The requirements are as follows:
There were N children playing the game in a circle. From the first child, the first child reported that 3 children left the game,
The remaining children continue to report data from the beginning, and the last person is the one after the loop by analogy.
Q: Where are the remaining persons in the original circle? Write code in Java
The procedure is as follows:
Public class shownum {</P> <p> Public static void main (string [] ARGs) {<br/> int [] arraynum = new int [14]; <br/> int outnum = 0; <br/> Int J = 1; <br/> int n = 0; <br/> for (INT I = 0; I <arraynum. length; I ++) {<br/> arraynum [I] = I + 1; <br/>}</P> <p> while (outnum <arraynum. length) {<br/> If (arraynum [(J-1) % arraynum. length]! =-1) {<br/> N ++; <br/> If (n = 3) {<br/> n = 0; <br/> outnum ++; <br/> system. out. print (arraynum [(J-1) % arraynum. length] + ""); <br/> arraynum [(J-1) % arraynum. length] =-1; <br/>}< br/> J ++; <br/>}</P> <p >}< br/>