以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助] (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=71625) |
-- 作者:zdq_1230 -- 发布时间:2015/7/15 10:19:00 -- [求助] 看了论坛中关于排列组合的帖子,指点一下 AddRange("a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t".split("?"))这句代码是什么意思? |
-- 作者:大红袍 -- 发布时间:2015/7/15 10:23:00 -- 把a b c d等,加入集合里面。这是一个便捷的写法而已
http://www.foxtable.com/help/topics/0217.htm
|
-- 作者:zdq_1230 -- 发布时间:2015/7/15 10:25:00 -- 是以?为分割符号,把字符串a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t分割成a b c d...等单个字符吗? |
-- 作者:大红袍 -- 发布时间:2015/7/15 10:26:00 -- 是的。 |
-- 作者:zdq_1230 -- 发布时间:2015/7/15 11:06:00 -- Dim nlist As new List(of String) nlist.AddRange("01?02?03?04?05?06".split("?")) Dim slist As new List(of String) Dim str As String For i As Integer = 0 To nlist.count -1 For j As Integer = 0 To nlist.count -1 For k As Integer = 0 To nlist.count -1 If i<>j AndAlso i <> k AndAlso j <> k Then str=nlist(i) & nlist(j) & nlist(k) If slist.Contains(str)=False Then slist.Add(str) End If End If Next Next Next For Each s As String In slist output.show(s) Next 我把上面的代码测试了一下,会出现010203、010302等情况,如果不考虑位置比如彩票选号,应该怎么改? |
-- 作者:大红袍 -- 发布时间:2015/7/15 11:09:00 -- Dim nlist As new List(of String) nlist.AddRange("01?02?03?04?05?06".split("?")) Dim slist As new List(of String) Dim str As String For i As Integer = 0 To nlist.count -1 For j As Integer = i+1 To nlist.count -1 For k As Integer = j+1 To nlist.count -1 \'If i<>j AndAlso i <> k AndAlso j <> k Then str=nlist(i) & nlist(j) & nlist(k) \'If slist.Contains(str)=False Then slist.Add(str) \'End If \'End If Next Next Next For Each s As String In slist output.show(s) Next |
-- 作者:zdq_1230 -- 发布时间:2015/7/15 11:16:00 -- 感谢高手 |