種(填數(shù)字)。 (2)請?jiān)诋嬀€處填入合適的代碼。 Const n=2000'物資總項(xiàng)數(shù) Const nc=26'物資種別數(shù),最多不會超過26 Dim items(1 To n)As String,supplies(1 To n)As String,totals(1 To n)As Long Dim g(1 To 2*nc)As Long'存儲各種物資3天、7天的需求數(shù)量 Dim b(1 To nc)As Long'存儲各種物資的庫存量 Dim c(1 To nc)As Long Dim q(1 To nc)As Integer Private Sub Form_Load ( ?。?br />'本過程讀取編號、品名、收支、需求的數(shù)據(jù)分別存儲在數(shù)組items、supplies、totals、g中,并在List1中顯示有關(guān)數(shù)據(jù);g數(shù)組中g(shù)(1)、g(2)存儲物資A的3天、7天的需求數(shù)量;g(3)、g(4)存儲物資B的3天、7天的需求數(shù)量……代碼略 '代碼略 End Sub Private Sub Command1_Click ( ?。?br />Dim i As Integer,j As Integer,k As Integer,top As Integer,bottom As Integer Dim r As Long,s As String,t As Integer,m As Integer For i=1 To nc b(i)=0:c(i)=0 Next i For i=1 To n'統(tǒng)計(jì)每種物資的庫存量 k=Asc(Mid(items(i),2,1))-Asc(“A“)+1
b(k)=b
b(k)=b
c(k)=i Next i j=0 For i=1 To nc If c(i)<>0 Then j=j+1:q(j)=i Next i top=0:bottom=j+1 j=1:k=bottom-1 Do While i<bottom '按各種物資的需求量進(jìn)行等級分類 m=q(j)
r=b(q(j))或r=b(m)
r=b(q(j))或r=b(m)
If r<g(2*m-1)Then top=top+1 If top<>j Then t=q(top):q(top)=q(j):q(j)=t j=j+1 ElseIf r>=g(2*m)Then bottom=bottom-1 t=q(j):q(j)=q(bottom):q(bottom)=t Else j=j+1 End If Loop List2.AddItem“編號 品名 庫存“ List2.AddItem“------“ For i=1 To k s=fp(i,top,bottom) List2.AddItem““& s &““& supplies(c(q(i)))&““& b(q(i)) Next i End Sub Function fp(pos As Integer,head As Integer,tail As Integer)As String If
pos<=head
pos<=head
Then fp=“A“ ElseIf pos<tail Then fp=“B“ Else fp=“C“ End If fp=fp & Mid(items(c(q(pos))),2,1) End Function