商品编号 | 商品名称 | 价格 | 单位 | 数量 | 配送单位 | 入库时间 |
001 | 商品1 | 39.8 | 盒 | 100 | 单位A | 2021.2.1 |
001 | 商品1 | 39.8 | 盒 | 200 | 单位B | 2021.2.3 |
003 | 商品3 | 19.8 | 袋 | 150 | 单位C | 2021.2.6 |
… | … | … | … | … | … | … |
下列关于“商品入库表”数据表的描述,正确的是( )
s = "python": b = 0
For i = 1 To Len(s) - 1
a = Abs(Asc(Mid(s, i, 1)) - Asc(Mid(s, i + 1, 1)))
If a > b Then b = a
Next i
Label1.Caption = Str(b)
执行该程序段后,标签Label1上显示的内容是( )
s1 = Text1.Text : s2 = Text2.Text
i = 1: j = 1: k = 1
Do While ⑴
If j > Len(s2) Or i <= Len(s1) And Mid(s1, i, 1) < Mid(s2, j, 1) Then
⑵
Else
⑶
End If
Loop
Text3.Text = s
上述程序段3个方框处的代码分别为( )
c = 0
For i = 1 To n - 1
k = i
For j = i + 1 To n
If a(j) < a(k) Then k = j
Next j
If i <> k Then
c = c + 1
t = a(i): a(i) = a(k): a(k) = t
End If
Next i
数组元素a(1)到a(6)的初始值依次是5,3,1,0,9,8,,执行该程序段后,变量c的值是( )
key = Val(Text1.Text)
s = ""
i = 1: j = 10
Do While i <= j
m = (i + j) \ 2
s = s + Str(m)
If a(m) = key Then Exit Do
If a(m) > key Then j = m - 1 Else i = m + 1
Loop
Label1.Caption = s
数组元素a(1)到a(10)依次存放10个升序的整数。在文本框Text1中输入一个任意整数执行该程序段,标签Label上中显示的内容可能的是( )
(提示:涨跌幅(%)=本期价格(元)-上期价格(元)/ 上期价格(元)*100)
图b
Private Sub Command1_Click()
Const n = 100
Dim ss As String, t As String, i As Integer
Dim k As Integer, p As Integer, temp As Integer
Dim s(1 To n) As Integer, f(1 To n) As Integer
Dim num(1 To n) As Integer, flag(1 To n) As Boolean
ss = Text1.Text
starttime = 480: endtime = 720 '教室可以安排活动时间为8:00到12:00
k = 0: p = 0
For i = 1 To Len(ss)
ch = Mid(ss, i, 1)
If ch <> "," Then
t = t + ch
Else
p = (k - 1) \ 2 + 1
If k Mod 2 = 1 Then s(p) = convert(t) Else f(p) = convert(t)
t = ""
End If
Next i
For i = 1 To p
num(i) = i
Next i
For i = 1 To p
List1.AddItem Str(num(i)) + " " + ff(s(i)) + " " + ff(f(i))
Next i
For i = 1 To p - 1
For j = p To i + 1 Step -1
If Then
temp = num(j): num(j) = num(j - 1): num(j - 1) = temp
temp = s(j): s(j) = s(j - 1): s(j - 1) = temp
temp = f(j): f(j) = f(j - 1): f(j - 1) = temp
End If
Next j
Next i
For i = 1 To p
If s(i) >= starttime And f(i) <= endtime Then
flag(i) = True
End If
Next i
List2.AddItem "活动号 起始时间 结束时间"
For i = 1 To p
IfThen
List2.AddItem Str(num(i)) + " " + ff(s(i)) + " " + ff(f(i))
End If
Next i
End Sub
Function convert(s As String) As Integer
'把时间格式的s转换为整数,如"08:20"转化为500。代码略
End Function
Function ff(t As Integer) As String
'把整数t转换为时间格式,如500转化为"08:20"。代码略
End Function
每段海明码编码方法如下:
插入二进制位:在第1、2、4、8位置上插入4个二进制位r1、r2、r3、r4,初值为0。把原8位二进制数d1~d8从左往右依次填入剩余位置中,原数据位和插入的二进制位如图a所示:
图a
计算插入的校验位的值:把每个位置号转换成4位二进制数,选出形如“***1”(“*”表示一位0或1)的位置号,则统计这些位置号对应数据位中的“1”的个数,若是奇数,则r1为1,否则为0;再选出形如“**1*”的位置号,则统计这些位置号对应数据位中的“1”的个数,若是奇数,则r2为1,否则为0;以此类推……
如8位二进制数“10101101”的编码过程如下:
1)插入4个二进制位,初值为0,剩余位置依次填入原数据位,如图b所示。
图b
2)计算插入的校验位的值,选出形如“***1”的位置号,即1、3、5、7、9、11,统计这些位置号对应数据位中“1”的个数为2,故r1=0,同理可得:r2=1,r3=0,r4=1,如图c所示。
图c
3)按位置号从小到大依次拼接各数据位得到最后编码“011001011101”。
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer, m As Integer
Dim s As String, ch As String, result As String
Dim a(1 To 12) As Integer, n(1 To 4) As Integer
Dim b(1 To 8) As Integer
b(1) = 3: b(2) = 5: b(3) = 6: b(4) = 7
b(5) = 9: b(6) = 10: b(7) = 11: b(8) = 12 '编码数据的插入位置
s = Text1.Text: result = ""
For i = 1 To Len(s) \ 8
For j = 1 To 12
a(j) = 0
Next j
For j = 1 To 8
ch = Mid(s, (i - 1) * 8 + j, 1)
'把编码数据插入相应位置
Next j
For j = 1 To 4
n(j) = 0
Next j
For j = 1 To 12
m = j
For k = 1 To 4
If m Mod 2 = 1 Then
m = m \ 2
Next k
Next j
For j = 1 To 4
a(2 ^ (j - 1)) =
Next j
For j = 1 To 12
result = result + Chr(Asc("0") + a(j))
Next j
Next i
Text2.Text = result
End Sub