編碼 | 書名 | 作者 | 銷售數(shù)量 | 銷售日期 | 價格 |
A | 《量子力學(xué)》 | *** | 16 | 2021/5/1 | 25.5 |
B | 《人工智能》 | *** | 16 | 2021/5/1 | 36.5 |
... | ... | ... | ... | ... | ... |
A | 《量子力學(xué)》 | *** | 2 | 2021/5/1 | 25.5 |
下列關(guān)于“銷售清單”數(shù)據(jù)表的描述,錯誤的是( )
Private Sub Command1_Click()
Dim s as string, k as string, i as integer
s = "*":k = "0"
For i = 1 To 5
k = k + "0":s = k + s
List1.AddItem s
Next i
End Sub
執(zhí)行該程序后,在窗體界面中顯示的結(jié)果是( )
n = Int(Rnd( ) * 4 + 4)
For i = 1 To 3
j = 1
Do While j <= n - i - 1
If a(j) > a(j + 1) Then
t = a(j):a(j) = a(j + 1):a(j + 1) = t
End If
j = j + 1
Loop
Next i
數(shù)組元素a(1)至a(7)的值依次為“16,35,18,11,23,17,32”,執(zhí)行該程序段后,數(shù)組a各元素的值不可能的是( )
Key = Val(Text1.Text): i = 1: j = 10
Do While i <= j
m = (i + j + 1) \ 2
t(m) = 2
If Key <= a(m) Then
j = m - 1
Else
i = m + 1
End If
Loop
For i = 1 To 10
s = s + t(i)
Next i
數(shù)組元素t(1)至t(10)初值均為0,數(shù)組元素a(1)至a(10)的值依次為“4,7,9,11,16,19,22,24,28,29”,在文本框Text1中輸入待查找數(shù),執(zhí)行該程序段后,下列選項中,s的值可能的是( )
圖a
每本書對應(yīng)一個唯一的書名編碼,請回答下列問題:
(提示:SUMIF函數(shù)用于對區(qū)域中滿足條件的單元格求和,例如:=SUMIF(B3:B9,B3,E3:E9),表示區(qū)域B3:B9中“書名”是“《量子力學(xué)》”的所有“小計”的和)
圖b
圖 b
Dim dd(0 To 100) As Integer '記錄所有訂單的取件距離
Dim fp(0 To 100) As Integer '存儲第x個快遞員取件的最遠(yuǎn)距離
Dim xs(0 To 100) As String
Private Sub Command1_Click()
Dim n As Integer,i As Integer,k As Integer,s As String
Dim left As Integer,right As Integer,m As Integer
Dim x As Integer,r As Integer
Randomize
s = Text1.Text: n = 1: i = 1
Do While i <= Len(s)
k = i: ch = Mid(s, k, 1)
Do While
k = k + 1: ch = Mid(s,k,1)
Loop
dd(n) = Val(Mid(s,i,k - i))
i = k + 1: n = n + 1
Loop
x = 1: fp(x) = dd(1)
For i = 2 To n - 1
left = 1
right = x
Do While left <= right
m = (left + right) \ 2
If Then
right = m - 1
Else
left = m + 1
End If
Loop
fp(r) = dd(i)
If r = x + 1 Then x = x + 1
Next i
Label2.Caption = "第" + Str(i - 1) + "件快遞將由第" + Str(r) + "號快遞員收取"
'列表框List1中顯示每位快遞員的收取情況,代碼略
End Sub
圖1
例如某天的銷售清單,庫存數(shù)據(jù)如圖2所示,根據(jù)每本書的警戒1和警戒2庫存,分組后的數(shù)據(jù)如圖3所示。
圖2
圖3
Dim stock(1 To 52) As Integer '存儲每本書警戒1和警戒2的庫存數(shù)量
Dim num(1 To 100) As Integer '存儲每本書每次的銷售數(shù)量
Dim bm(1 to 26) As String '存儲每本書的書名編碼
Dim kc(1 To 26) As Integer '存儲每本書的庫存數(shù)量
Dim sell(1 To 26) As Integer,q(1 To 26) As Integer
Private Sub Form_Load()
'從數(shù)據(jù)庫讀取書目銷售清單數(shù)據(jù),顯示在list1中,分別存在數(shù)組
'stock(1),stock(2)存書名編碼A的警戒1庫存,警戒2庫存;stock(3),stock(4)存書名編碼B的警戒1庫存,警戒2庫存,依次類推,代碼略
End sub
Private Sub Command1_Click()
For i = 1 To 100 '處理100條銷售清單數(shù)據(jù)
k = Asc(bm(i)) - 64
Next i
n = 0
For i = 1 To 26 '更新庫存數(shù)據(jù)
If sell(i) > 0 Then
n = n + 1
kc(i) = kc(i) - sell(i)
End If
Next i
head = 0: tail = n + 1: j = 1
Do While j < tail
r = kc(q(j))
If r <= stock(2 * q(j) - 1) Then
head = head + 1
If Then t = q(head): q(head) = q(j): q(j) = t
j = j + 1
ElseIf r > stock(2 * q(j)) Then
tail = tail - 1
t = q(j): q(j) = q(tail): q(tail) = t
Else
j = j + 1
End If
Loop
'分組排序及排序后數(shù)據(jù)顯示在列表框list2中,代碼略
End Sub