题型:综合题 题类:模拟题 难易度:困难
浙江省教育绿色评价联盟2020届高三信息技术6月适应性考试试卷
编号 |
1 |
2 |
3 |
4 |
5 |
生产时间 |
4 |
7 |
5 |
5 |
9 |
商品价值 |
10 |
16 |
12 |
10 |
15 |
若生产时间为20,则可生产编号为1、2、5的商品,总价值为10+16+15=41。
编写一个VB程序,实现如下功能:在文本框Text1中依次输入各商品(数量小于等于10件)的生产时间和价值(整数用逗号分隔并以逗号结尾),在文本框Text2中输入总加工时间(至少可以生产一件商品),单击“确定”按钮Command1后,在列表框List1中显示最大的总价值和生产的商品编号。程序运行界面如图所示。
Private Sub Command1_Click()
Dim n As Integer, i As Integer, j As Integer, k As Integer, c As Integer, p As Integer
Dim temp As xue Integer, sum1 As Integer, sum2 As Integer, max As Integer, ans As Integer Dim s As ke String, wang ch As String, v(1 To 10) As Integer, t(1 To 10) As Integer
s = Text1.Text
n = Val(Text2.Text)
c = 00: k = 0
For i = 1 To
ch = Mid(s, i, 1)
If ch <> "," Then k = k + 1
Else
c = c + 1
temp = Val(Mid(s, i - k, k)) k = 0
If c Mod 2 = 1 Then t(p) = temp Else v(p) = temp
End If
Next i
c = c \ 2
For i = 1 To 2 ^ c - 1 k = i: j = c
Do While k > 0
IfThen sum1 = sum1 + v(j): sum2 = sum2 + t(j): j = j - 1
k = k \ 2 Loop
If max < max = sum1: ans = i sum1 = 0: sum2 = 0
Next i
List1.AddItem "最大价值是:" + Str(max)
List1.AddItem "生产商品如下:" ‘输出生产的商品,代码略
End Sub
试题篮