把一个数列中所有的相同的数删的只剩一个,VB啊

问题描述:

把一个数列中所有的相同的数删的只剩一个,VB啊

dim a(10),b(),i,j,k,c'对数组a(0)~a(10)赋值.for i=0 to 10if i>0 thenc=0for j=0 to i-1if a(j)=a(i) then c=1:exit fornextend ifif c=0 thenredim preserve b(k)b(k)=a(i)k=k+1end ifnext i数组...能不能写得详细点,怎么做,版面按钮设计你的题目也没写清楚啊,数组怎么赋值?是输入还是随机数?先输入数,最后点击按钮删除相同数窗体里面放个按钮,完整代码如下:Private Sub Command1_Click()Dim a(9), b(), i, j, k, c '数组含有10个数Print "原数组:"For i = 0 To 9a(i) = Val(InputBox("第" & i + 1 & "个数"))Print a(i) & "";If i > 0 Thenc = 0For j = 0 To i - 1If a(j) = a(i) Then c = 1: Exit ForNextEnd IfIf c = 0 ThenReDim Preserve b(k)b(k) = a(i)k = k + 1End IfNext iPrint vbCrLf & "删除重复数值后的数组:"For i = 0 To UBound(b)Print b(i) & "";NextEnd Sub