Joseph's programming implementation

xiaoxiao2021-04-10  514

Title: There are 15 Japanese people and 15 Americans on a hot air ball. Because hot air balloons are overweight, they must jump to 15 people. According to the rules of the discussion, from the first person, the ninth person is selected to jump, and so on. There are only 15 Americans left on the final hot air ball, and write a program to print the 15 Japanese locations.

My implementation procedure is as follows:

Package com.pclib.www;

Public class josephus {public static void main (string args []) {int p [] = new int = new int = new int [15]; / / result for (int i = 0; I = 15) {Break } If (p [i% 30] == - 1) Continue; k = k% 9; if (k == 0) {stat ; system.out.print (p [i% 30] 1 "" ); P [i% 30] = -1;} k ;}}}

Running: 9 18 27 6 16 26 7 19 30 12 24 8 22 5 23

This issue appears in the 9CBS community: http://community.9cbs.net/expert/topic/4835/4835542.xml? Temp = .1591608

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

New Post(0)