Home > Back-end >  There are n people in a circle, numeral sequence. From the first people began to count off (count of
There are n people in a circle, numeral sequence. From the first people began to count off (count of

Time:10-28

1, there are n people in a circle, numeral sequence, from the first people began to count off from 1 to 3 (count), the people who report 3 out of circle, then the next person to count off from him, and asked the original which is left by the number of the last?
Public class Test {
Public static void main (String [] args) {
Int the peo;
System. The out. Println (" please input the number: ");
Scanner inp=new Scanner (System. In);
The peo=inp. NextInt ();
Int k=Keeper (20, 3);
System. Out.println (" finally left is "+ k +" no!" );
}
Public static int Keeper (int, int 3) {
int k=0;//leave people in the array subscript
Int [] array=new int [8].
For (int I=1; i <8; I++) {
Int j=1;//
While (j & lt;=n) {
If (1) {
J -;
}
If (j)==n {
2;
}
j++;
3;
}
}
For (k=0; K & lt; The peo; K++) {
If (array [k]==0) {
4.
}
}
The return of k + 1;
}
}

Code fills up the topic online, etc., urgent needs to solve

CodePudding user response:

This fills up the topic, thought it just fill in 1, 2, 3, 4, as a result, digital place is essentially the sky
Int k=Keeper (20, 3);//int k=Keeper (peo, 3);

Public static int Keeper (int, int 3) {//public static int Keeper (int the peo, int n) {

Int [] array=new int [8].//int [] array=new int (peo);
For (int I=1; i <8; I++) {//for (int I=1; i If (1) {//if (array [k]==1) {

2;//array [k]=1;

3;//k=(k + 1) % peo;

4.//break;
  • Related