主题:VB操作 数据结构线性表
题目:已知一顺序表A,其元素非递减有序排列,编写一个算法,删除顺序表中多余的值相同的元素。(用VB编写)以下是本人编写的程序;
Option Base 1
Dim data
Dim datalen As Integer
Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
i = 1
Do While i <= datalen - 1
If data(i) <> data(i + 1) Then
Print data(i);
i = i + 1
Else
For j = i To datalen - 1
data(j) = data(j + 1)
Print (j);
Next
datalen = datalen - 1
j = j + 1
End If
Loop
End Sub
Private Sub Form_Load()
End Sub
Private Sub MakeList_Click()
data = Array(720, 1200, 1200, 2160, 2160, 2160, 3000, 3000, 3000, 1680)
For i = 1 To 10
Print data(i);
Next i
Print
datalen = 10
End Sub
编写之后不知道哪里出错了,总是不能成功运行,理想的运行结果是,当程序结束后能够显示删除多余元素后的线性表,但是总是不能成功,希望大家帮忙看看,谢谢了!!!
Option Base 1
Dim data
Dim datalen As Integer
Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
i = 1
Do While i <= datalen - 1
If data(i) <> data(i + 1) Then
Print data(i);
i = i + 1
Else
For j = i To datalen - 1
data(j) = data(j + 1)
Print (j);
Next
datalen = datalen - 1
j = j + 1
End If
Loop
End Sub
Private Sub Form_Load()
End Sub
Private Sub MakeList_Click()
data = Array(720, 1200, 1200, 2160, 2160, 2160, 3000, 3000, 3000, 1680)
For i = 1 To 10
Print data(i);
Next i
datalen = 10
End Sub
编写之后不知道哪里出错了,总是不能成功运行,理想的运行结果是,当程序结束后能够显示删除多余元素后的线性表,但是总是不能成功,希望大家帮忙看看,谢谢了!!!