从用户输入一个数字并安排数字出现,例如用户输入为411555698,输出应为514689 [英] take a number input from user and arrange the number occurrence for instance user input is 411555698 output should be 514689

查看:82
本文介绍了从用户输入一个数字并安排数字出现,例如用户输入为411555698,输出应为514689的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//从用户那里获取一个数字输入并在重复出现时排列数字,即,重复的数字应首先出现,而不重复的数字应按顺序出现。例如用户输入是411555698输出应该是514689

//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

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));

}

推荐答案

首先考虑一下这个问题:



  • 有什么要求?
  • 有什么输入?
  • 输出是什么?
  • 什么是转换规则?
  • 任何规则的例外情况是什么?
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?


我们不做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!
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!


这篇关于从用户输入一个数字并安排数字出现,例如用户输入为411555698,输出应为514689的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆