dim deshu as long '这里定义数的变量名称
if xxx=xxx then
deshu = 1
end if
一直循环到deshu = 20然后
if deshu >= 1 then
我要在这里取所有得出的数里最小的一个数.应该怎么写?
end if

解决方案 »

  1.   

    最简单的就是循环一遍,只要小于上一个就赋值给一个变量,否则下一个
    例如
    dim intresult as integer
    intresult = deshu(1)
    for intI=2 to 20
        if deshu(intI) < intresult then intresult = deshu(intI)
    next
    这样intresult就是最小的了
      

  2.   

    楼上的请参考此贴:
    http://community.csdn.net/Expert/topic/5005/5005438.xml?temp=.2016413
      

  3.   

    province_(雍昊) 
    呵呵,也是一次循环dim intI as integer
    dim intMin as integer
    dim intSubMin as integerintMin = deshu(1)
    intSubMin = deshu(1)
    for intI=2 to 20
        if intMin = intSubMin then 
            if deshu(intI) > intMin then 
                intSubMin = deshu(intI)
            elseif deshu(intI) < intMin then 
                intMin = deshu(intI)
            end if
        end if
        if deshu(intI) > intMin and deshu(intI) < intSubMin then 
            intSubMin = deshu(intI)
        elseif deshu(intI) < intMin then
            intSubMin = intMin
            intMin = deshu(intI)
        end if
    next
    这样intMin是最小的,intSubMin是次小。
    随手写的,未经测试,一会儿再挑错
      

  4.   

    dim intI as integer
    dim intMin as integer
    dim intSubMin as integerintMin = deshu(1)
    intSubMin = deshu(1)
    for intI=2 to 20
        if deshu(intI) < intMin then 
           intSubMin = intMin
           intMin = deshu(intI)
        elseif deshu(intI) < intSubMin then 
           intSubMin = deshu(intI)
        end if
    next