Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
//take a number input from user and arrange the number in its repeating occurrence ie., the number which is repeating more should come first and those who are not repeating should be in sequence. for instance user input is 411555698 output should be 514689
Java
public static void main(String[] args) {
    Integer[] arr = new Integer[1000];
    for (int i = 0; i < arr.length; i++) {
        arr[i] = i;
    }
    Collections.shuffle(Arrays.asList(arr));
    System.out.println(Arrays.toString(arr));

}
Posted
Updated 31-Oct-14 22:31pm
v5
Comments
What is the question?

Think first about the problem:

  • what are the requirements?
  • what are the inputs?
  • what are the outputs?
  • what are the transformation rules?
  • what are the exceptions to any rules?

Once you have identified these you can start documenting the steps required to solve the problem. Only then can you start writing your code.
 
Share this answer
 
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900