本文介绍了(Java)查找数组中的所有可能对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试做这样的事情时,我意识到我真的需要去大学!
Its when I try to do stuff like this I realise I really need to go to university!
无论如何我有一个字符串数组(275)我需要循环遍历它们并在java中创建所有可能对的字符串。
Anyway I have an array of strings (275) I need to loop through them and create strings of all the possible pairs, in java.
我一直在学习递归,但我找不到答案。
I've been learning about recursion but I cant find the answer for this.
谢谢
推荐答案如果对 ab 和 ba 不同,请执行:
In case pairs ab and ba are different, do:
for i=0 to array.length for j=0 to array.length if i == j skip else construct pair array[i], array[j]如果没有,请执行以下操作:
and if not, do something like this:
for i=0 to array.length-1 for j=i+1 to array.length construct pair array[i], array[j]请注意,我假设数组包含唯一的字符串!
Note that I am assuming the array holds unique strings!
更多推荐
(Java)查找数组中的所有可能对
发布评论