登记序号 | 姓名 | 门牌号 | 登记日期 | 登记形式 | 是否绿码 |
20200101 | 王立 | 06-801 | 2020.01.29 | 门卫 | 是 |
20200102 | 张哲民 | 01-203 | 2020/02/12 | 上门排查 | 是 |
20200103 | 李圣达 | 11-206 | 2020/02/12 | 电话访问 | 否 |
… | … | … | … | … | … |
下列说法正确的是( )
ans = 0: i = 1
Do While i < Int(Sqr(n))
If n / i = Int(n / i) And n / i Mod 2 = 1 Then
ans = ans + 1
End If
i = i + 2
Loop
若变量n的值为81,则执行该程序段后,变量ans的值为( )
s1 = Text1.Text: s2 = "" n = Len(s1)
i = 1: j = n
Do While i <= j
If i Mod 2 = 1 Then
s2 = s2 + Mid(s1, j, 1)
Else
s2 = Mid(s1, n - j + 1, 1) + s2
End If
i = i + 1
j = j - 1
Loop
Text2.Text = s2
在文本框Text1中输入“python”,执行该程序段后,文本框Text2中显示的是( )
a(1) = 12
For i = 2 To 10
a(i) = a(i - 1) + Int(Rnd * 10) + 1
Next i
i = 1: j = 10: c = 0: key = 15
Do While i <=j
m = (i + j) \ 2
c = c + 1
If a(m) = key Then
Exit Do
ElseIf a(m) < key Then
i = m + 1
Else
j = m - 1
End If
Loop
执行该程序段后,变量c的值不可能为( )
Dim a(1 To 15) As Integer, num As Integer, s As String
'生成数组a,a(1)=73,a(2)=58, a(3)=62, a(4)=36…代码略
Private Sub Command1_Click()’对数组进行排序
num = 5: k = 1: f = 1
For i = 1 To num
k = k + i
For m = k - i To ①
For n = k - i To 2 * k - 2 - i - m
If ② Then t = a(n): a(n) = a(n + 1): a(n + 1) = t
Next n
Next m
f = f * (-1)
Next i
'将处理后的数组,以金字塔形显示,代码略
End Sub
模块名:“Main”场景 |
类别序号:2 |
进入方式:由“load”场景单击“播放”按钮进入 |
呈现方式: ⒈鱼在舞台的下方移动,文字在左侧 ⒉菊花开始时在舞台上方,慢慢向右移出舞台 ⒊“重播”按钮在舞台右下方,单击“重播”按钮,将从该场景第一帧开始播放。 |
呈现顺序说明: ⒈一开始出现文字和鱼游动的动画,持续到场景结束。 ⒉约第2.5秒时出现“菊花”的动画,时长约2.5 秒。 ⒊最后出现“重播”按钮,并停止播放。 |
图a
图b
请回答下列问题:
A.(10,10) B.(550,10) C.(10,440) D.(-550,440)
例如:若n=4,4个仓库中的疫苗数分别为50、13、80、27。若m=2,最小差值为10;若m=3,最小差值为40。
编写VB程序模拟上述功能,在文本框Text1中输入n(n≤15),在文本框Text2中输入m(m≤4),随机生成n个两位正整数,在列表框List1中输出。单击“计算”按钮Command1,在文本框Text3中输出最小差值,在列表框List2中输出每个国家获得疫苗的方案。程序运行界面如图所示。
Private Sub Command1_Click()
Const maxn = 15
Dim n As Integer, i As Long, j As Long, k As Long, p As Integer, m As Integer
Dim a(1 To maxn) As Long, f(1 To maxn) As Long
Dim s(1 To maxn) As String, max As Long, min As Long, ans As Long, ansi As Long
n = Val(Text1.Text): m = Val(Text2.Text)
List1.Clear: List2.Clear: Randomize
For i = 1 To n
①
List1.AddItem Str(a(i))
Next i
ans = 10000
For i = 1 To m ^ n '枚举所有的分配方案
For j = 1 To m
f(j) = 0
Next j
j = i: max = 0: min = 10000
For k = 1 To n
f(p) = f(p) + a(k)
j = j \ m
Next k
For k = 1 To m
If f(k) > max Then max = f(k)
If f(k) < min Then min = f(k)
Next k
If ② Then
ans = max - min
③
End If
Next i
Text3.Text = Str(ans)
For i = 1 To n
j = ansi Mod m
s(j + 1) = s(j + 1) + Str(a(i))
ansi = ansi \ m
Next i
For i = 1 To m
List2.AddItem s(i)
Next i
End Sub
① ② ③
1)这两项运动在记录中必须连续出现,不能被其他运动打断,如“1,2,2,1,2”是一种可能的结果;“1,2,2,1,2,3”则不是可能的结果;
2)这两项运动在记录中出现的次数必须是最多的一种组合。
运动记录 |
1,1,2,3,2,3,2,3,3,1,1,4,3 |
||||
序号 |
① |
② |
③ |
④ |
⑤ |
两项运动 |
1,1,2 |
2,3,2,3,2,3,3 |
3,3,1,1 |
1,1,4 |
4,3 |
从上表分析可知,小张在一段时间内连续进行的两项运动有5种不同组合,其中组合②中的两项运动持续时间最长,所以最“喜爱”的两项运动为2和3,共连续进行了7次。
根据算法思想,编写VB程序实现如下功能:程序初始化时读取小张记录的一段时间内的所有运动项目,以逗号间隔显示在文本框Text1中,单击“寻找运动项目”按钮Command1,在标签Label4上显示最喜爱的两项运动编号,在文本框Text2中显示这两项运动最长持续的次数。程序运行界面如图所示。
Dim a(1 To 100) As Integer, n As Integer
Private Sub Form_Load( )
'读取已有记录项目总数n
'读取记录的每次运动项目存入数组 a,并在文本框Text1中显示,代码略
End Sub
Private Sub Command1_Click()
Dim x As Integer, y As Integer 'x, y分别表示当前记录中两个不同项目
Dim c1 As Integer, c2 As Integer 'c1,c2 分别表示两个项目在当前统计过程中出现的次数
Dim i As Integer, j As Integer, m1 As Integer, m2 As Integer, ans As Integer
i = 1: j = 1
Do While j <= n And a(i) = a(j)
j = j + 1
Loop
x = a(i): y = a(j)
c1 =
c2 = 1
ans = j - i + 1
Do While j < n
j = j + 1
If a(j) = x Then
c1 = c1 + 1
ElseIf a(j) = y Then
c2 = c2 + 1
Else
Do While
If a(i) = x Then c1 = c1 – 1 Else c2 = c2 - 1
i = i + 1
Loop
If Then
y = a(j)
c2 = 1
Else
x = a(j)
c1 = 1
End If
End If
If ans < j - i + 1 Then
ans = j - i + 1
m1 = x
m2 = y
End If
Loop
Label4.Caption = Str(m1) + "和" + Str(m2)
Text2.Text = Str(ans)
End Sub