Joseph Ring Question:
Package com.zb.test;
public class Yuesefu
{
public static void Main (string[] args)
{
500 people Group
Boolean[] B = new boolean[500];
for (int i = 0;i < b.length;i++)
{
B[i] = true;//means that everyone is alive.
}
int sum = b.length;//Total is 500
int index = subscript for number of 0;//
int count = 0;//a variable
while (Sum > 1)//When the number of surviving >1 people
{
if (B[index])//If this person is alive at the moment
{
count++;//to the number of reports
if (count = = 3)//If report 3 is shot
{
Total sum--;//-1
B[index] = false;//This person is now dead.
Count = 0;//Restart off
}
}
index++;//subscript move to next person
if (index = = 500)//if subscript to 500 means 1 laps have ended re-counting
{
index = 0;
}
}
for (int i = 0;i < b.length;i++)
{
if (B[i])
{
System.out.println ("The Living position is:" + (i+1));
}
}
}
}
Method
GetMethod: Gets the public-decorated method of a class if there is a method that inherits the parent class that exists in the subclass
Getdeclaremethod: Gets the method declared in the class even if it is decorated with private
Implementing object-Oriented Programming with Java (11)