Home > Back-end >  Which members of particular rule ordering?
Which members of particular rule ordering?

Time:12-02

Specific rules sort
We have two boxes, one of the boxes put respectively in increasing order of the numbered 1-100 100 balls, now our words from the box on the number of the first ball in order to the ball, whenever count to three, to take out the location of the ball from the, into another box, and then continue to start from the next ball number 1, when the count to 3, remove the ball into another box, take out the back of the ball before, so repeatedly, until the number to the last ball, return to the first ball position, count not interrupt, until the word is only a small ball in the box,
Question 1, how much is this ball of digital,
2, another box of word ball number order, with most familiar programming language or pseudo code, write the problem solving method, or explain their thinking,

CodePudding user response:

1. This is not sorted
2. Use LinkedList
3. While loop
4. Simple several time cycle time, reduce the cycle can be directly add 3, completes the set length judge good
5. Simply isn't worth mentioning another box order
6. The question is very simple, you can do what I say

CodePudding user response:

Thank you, help to me

CodePudding user response:

refer to the second floor of the style of the virtual world reply:
thank you, help me


 
Public class Test2 {

Public static void main (String [] args) {
//TODO Auto - generated method stub
Int [] s=new int [100].
List list=new ArrayList (a);
Stream. Iterate (0, X-ray & gt; X + 1). Limit (100). The forEach (x & gt; S [x]=x + 1);
int count=0;
int i=0;
For (; List. The size () & lt; 99;) {
If (s [I]!=0) {
The count=(count + 1) % 3;
If (count==0) {
List. Add [I] (s);
S [I]=0;
}
}
I=(I + 1) % 100;
}
For (int x=0; X & lt; 100; X++) {
If (s [x]!=0)
System. The out. Printf (" % 5 d, "s [x]).
}
System.out.println();
For (int x=0; X & lt; List. The size (); X++) {
System. The out. Printf (" % 5 d, "list. Get (x));
If ((x + 1) % 10==0)
System.out.println();
}
}

}

CodePudding user response:

Wow! You are too good, please give me the code directly to write out
  • Related