(Java)查找数组中的所有可能对

编程入门 行业动态 更新时间:2024-10-27 06:33:58
本文介绍了(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)查找数组中的所有可能对

本文发布于:2023-11-30 00:27:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648114.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:能对   组中   Java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!