想要随机交换多位数的数字 [英] Want to swap digits of multiple digit num randomly
本文介绍了想要随机交换多位数的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个四位数的数字,例如: - 1234我将像智慧3241一样随机交换,即以任何顺序....不要反向???
我尝试了什么:
i已经尝试过精神但没有办法写这个
解决方案
忘记他们是数字。如果是随机字母怎么办?你会做什么?
提示:通过随机选择一个成员并将其移动到新数组,将一个数组映射到另一个数组。
您需要解决的问题:
- 如何随机选择一个角色
- 如何不多次挑选同一个角色。
拿一张纸纸张,铅笔和练习。
您不需要直接获得算法。
请注意您遵循的步骤,将其作为一个程序,改进以适应特定于计算机的帐户部分。
- 学习一种或多种分析方法可能对您有帮助, EW Djikstra自上而下的方法是一个良好的开端。
https:// en.wikipedia.org/wiki/Top-down_and_bottom-up_design [ ^ ]
https://en.wikipedia.org/wiki/Structured_programming [ ^ ]
https://en.wikipedia.org/wiki/Edsger_W._Dijkstra [ ^ ]
https://www.cs.utexas.edu/users/EWD/ewd03xx/EWD316.PDF [ ^
Like if i have a four digit number eg:- 1234 i would be swaped randomly like wise 3241 i.e in any order....not to be reverse???
What I have tried:
i have tried mentally but not get any way to write this
解决方案
Forget about them being numbers. What if it were for random letters? What would you do?
Hint: map one array to another, by randomly selecting a member and moving it to the new array.
Problem for you to solve:
- How to randomly pick a character
- How to not pick the same character more than once.
Take a sheet of paper, a pencil and practice.
You don't need to get directly an algorithm.
Note the steps you follow, make it a procedure, refine to take into account parts specific to computers.
- Learning one or more analyze methods may help you, E.W. Djikstra top-Down method is a good start.
https://en.wikipedia.org/wiki/Top-down_and_bottom-up_design[^]
https://en.wikipedia.org/wiki/Structured_programming[^]
https://en.wikipedia.org/wiki/Edsger_W._Dijkstra[^]
https://www.cs.utexas.edu/users/EWD/ewd03xx/EWD316.PDF[^]
这篇关于想要随机交换多位数的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文