| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 390 人关注过本帖
标题:求从杂乱无章的数列中提取非降序数列段的算法
只看楼主 加入收藏
黝黑蜗壳
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-10-9
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
求从杂乱无章的数列中提取非降序数列段的算法
如题。。。 想了几天也没明白
这是我的算法 但是有问题 不知道问题在哪 还望指教
Private Sub Command1_Click()
'Dim counter As Integer, i As Integer, x As Integer
    Open App.Path & "\数据.txt" For Input As #1
        Do While Not EOF(1)
        Line Input #1, temp
        x = x + 1
        Loop
    Close #1
'Dim sj(60000)
i = 1
    Open App.Path & "\数据.txt" For Input As #2
        While Not EOF(2)
        Input #2, sj(i)
        i = i + 1
        Wend
    Close #2

For counter = 1 To x - 1
    'Select Case sj(counter)
        'Case Is <= sj(counter + 1) And Text1.Text <> ""
            'Text1.Text = Text1.Text & vbNewLine & sj(counter)
            'GoTo end_:
        'Case Is <= sj(counter + 1) And Text1.Text = ""
            'Text1.Text = sj(counter)
            'GoTo end_:
        'Case Is >= sj(counter - 1) And sj(counter) <= sj(counter + 1) And Text1.Text <> ""
           ' Text1.Text = Text1.Text & vbNewLine & sj(counter)
            'GoTo end_:
        'Case Is >= sj(counter - 1) And sj(counter) <= sj(counter + 1) And Text1.Text = ""
            'Text1.Text = sj(counter)
            'GoTo end_:
'end_:
    'End Select
    If sj(counter) <= sj(counter + 1) And Text1.Text <> "" Then
        Text1.Text = Text1.Text & vbNewLine & sj(counter)
    ElseIf sj(counter) <= sj(counter + 1) And Text1.Text = "" Then
        Text1.Text = sj(counter)
    ElseIf sj(counter) >= sj(counter - 1) And sj(counter) <= sj(counter + 1) And Text1.Text <> "" Then
        Text1.Text = Text1.Text & vbNewLine & sj(counter)
    ElseIf sj(counter) >= sj(counter - 1) And sj(counter) <= sj(counter + 1) And Text1.Text = "" Then
        Text1.Text = sj(counter)
    End If
Next
End Sub
搜索更多相关主题的帖子: counter 
2014-10-09 10:48
yangfrancis
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:贵宾
威 望:141
帖 子:1510
专家分:7661
注 册:2014-5-19
收藏
得分:20 
首先要有一个dim used(1 to x-1) as boolean
...'全部赋值为false
从第二项开始,只考虑
if sj(counter)>=sj(counter-1) then
   if not used(counter-1) then
           ...'输出第counter-1项
           used(counter-1)=true
   end if
   if not used(counter) then
           ...'输出第counter项
           used(counter)=true
   end if
end if
2014-10-10 22:50
快速回复:求从杂乱无章的数列中提取非降序数列段的算法
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013628 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved