如何获得组合专家的每一个组合



我有一个程序,您可以在其中导入组合,例如

test:lol
hello:hi
sup:hey

第一个是"用户名",最后一个是"密码"。我想让每个用户名都有一行与列表中的每个密码。我希望所有这些都放在一个单独的字符串列表中。

例如:

test:lol
test:hi
test:hey
hello:lol
hello:hi
hello:hey
sup:lol
sup:hi
sup:hey

我认为这可能是一个非常简单的代码,首先将列表分为两个列表,然后为每个用户名添加每个密码,但我的大脑真的想不出任何解决方案。

提前感谢:)

是的,你说得对。Firs-通过按列分隔每个字符串来获得两个列表userspasswords。第二个遍历CCD_ 3和CCD_。伪码
foreach uName in users do
    foreach pwd in passwords do
        print user.concat(":").concat(pwd)
    end
end

说明:

Get first `uName` from `users`
    Get first `pwd` from `passwords`
        output "`user`:`pwd`"
    Get second `pwd` from `passwords`
        output "`user`:`pwd`"
    ...
Get second `uName` from `users`
    Get first `pwd` from `passwords`
        output "`user`:`pwd`"
...

如果有什么不清楚的地方,请随时询问

最新更新