回覆列表
  • 1 # o鬍子先生o

    一種方法可以用redim prezserve 改變動態陣列大小新增不重複值實現 也可以用字典,利用字典的鍵不可重複這一特點,不斷新增鍵值對,最後輸出所有的鍵就可以了

  • 2 # 小嘟嘟熊

    方法1

    dim a(9) as integr

    dim b() as integer

    dim i as integer,j as integer

    redim preserve b(0)

    b(0)=a(0)

    for i= 1 to ubound (a)

    for j= 0 to ubound(b)

    if a(i) = b(j) then goto net ,有相同的就跳出

    next

    redim preserve b(ubound(b)+1)

    b(ubound(b))=a(i)

    net: ,跳到這裡,匹配下一個資料

    next

    a = b

    方法2,有10個數,先找出最大的數,按照這個數定義一個數組,把對應的值寫入對應的元素中,最好先設定一個預設值

    dim a(9) as integer

    dim i as integer,temp as integer

    temp=a(0)

    for i= 1 to ubound(a)

    if a(i) > temp then

    temp = a(i)

    end if

    next i

    redim b(temp) as integer

    for i= 0 to ubound(a)

    b(a(i)) = a(i)

    next

  • 中秋節和大豐收的關聯?
  • 悼念剛逝去的親人都有什麼古詩?