以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 求助怎么写这个函数? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=141754) |
-- 作者:rongping -- 发布时间:2019/10/10 12:48:00 -- 求助怎么写这个函数? 我想写这么一个函数: 我通过参数1传进去一个数组,通过参数2的值计算,通过参数3 确定正反。 比如我传进去这么一个数组, Dim s1() As String = {"命宫","父母","福德","田宅","官禄","仆役","迁移","疾厄","财帛","子女","夫妻","兄弟"} 如果我参数2的值是5,参数3为0代表正转,那么返回的数组是以下内容: {"财帛","子女","夫妻","兄弟","命宫","父母","福德","田宅","官禄","仆役","迁移","疾厄"} 再如我参数2的值是5,参数3为1代表反转.那么返回的数组是以下内容: {"官禄,"田宅","福德","父母","命宫","兄弟","夫妻","子女","财帛","疾厄","迁移","仆役"} 请问该如何写这个函数? |
-- 作者:有点蓝 -- 发布时间:2019/10/10 13:51:00 -- 如果我参数2的值是5,参数3为0代表正转,那么返回的数组是以下内容: {"财帛","子女","夫妻","兄弟","命宫","父母","福德","田宅","官禄","仆役","迁移","疾厄"} 没看懂,结果怎么来的,和参数2有啥关系? |
-- 作者:rongping -- 发布时间:2019/10/10 14:24:00 -- Dim s1() As string = Args(0) \\\\这是传进去的数组参数 比如Dim s1() As String = {"子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"}Dim i As integer = Args(1) \\\\这是传进去数组的引用参数,如果是5代表数组的第4个参数 引用的是s1(4)
Dim z As integer = Args(2) \\\\这是代表排序是逆时针还是顺时针
|
-- 作者:有点蓝 -- 发布时间:2019/10/10 14:41:00 -- Dim s1() As String = {"命宫","父母","福德","田宅","官禄","仆役","迁移","疾厄","财帛","子女","夫妻","兄弟"} 如果我参数2的值是5,参数3为0代表正转,那么返回的数组是以下内容: {"财帛","子女","夫妻","兄弟","命宫","父母","福德","田宅","官禄","仆役","迁移","疾厄"} 如果是5代表数组的第4个参数 引用的是s1(4),那么s1(4)不用应该是"官禄"?和上面的第二个结果有什么关系? |
-- 作者:rongping -- 发布时间:2019/10/10 15:17:00 -- 如果参数2的值是5,顺时针。结果是把传入进来的数组第一个值放到第5个位置,然后其他的统一向后移过去,首位相连。就是这个意思 |
-- 作者:rongping -- 发布时间:2019/10/10 15:29:00 -- 可能这样表达更直观一点: 这个是传进去的数组 Dim s1() As String = {"1","2","3","4","5","6","7","8","9","10","11","12"}
我想要实现的返回值顺时针(假设参数2的值是5)结果是: {"9","10","11","12","1","2","3","4","5","6","7","8"} 逆时针的结果是: {"5","4","3","2","1","12","11","10","9","8","7","6"} |
-- 作者:有点蓝 -- 发布时间:2019/10/10 15:56:00 -- Dim s1() As String = {"1","2","3","4","5","6","7","8","9","10","11","12"} Dim i1 As Integer = 5 Dim i2 As Integer = 0 Dim lst As new List(of String) If i2 = 0 Then For i As Integer = 0 To s1.Length - i1 lst.Add(s1(i)) Next For i As Integer = s1.Length - 1 To s1.Length - i1 + 1 Step -1 lst.Insert(0,s1(i)) Next Else For i As Integer = i1-1 To 0 Step -1 lst.Add(s1(i)) Next For i As Integer = s1.Length - 1 To i1 Step -1 lst.Add(s1(i)) Next End If Output.Show(String.Join(",",lst.ToArray))
|
-- 作者:rongping -- 发布时间:2019/10/10 16:04:00 -- 超级感谢! |