题型:综合题 题类:模拟题 难易度:困难
浙江省丽水、湖州、衢州三地市2021届高三下学期信息技术4月教学质量检测
编写程序,实现上述功能:在文本框Text1中输入偶数n,单击“生成”按钮Command1,在列表框List1中显示初始矩阵,在文本框Text2中输入偶数m(2≤m≤ n),单击“处理”按钮Command2,在列表框List2显示处理结果。程序运行界面如图c所示。
请回答下列问题:
Dim n As Integer
Dim a(1 To 100 * 100) As String
Private Sub Command1_Click()
Dim i As Integer
n = Val(Text1.Text)
If n <= 100 And n >= 2 And n Mod 2 = 0 Then
For i = 1 To n * n
a(i) = Chr() ‘字符"0"的ASCII码值为48
'将初始矩阵显示列表框List1中,代码略
Next i
Else
List1.AddItem "输入有误"
End If
End Sub
Private Sub Command2_Click()
Dim b(1 To 100 * 100) As String, s As String
Dim m As Integer, y As Integer, i As Integer, R As Integer, C As Integer
m = Val(Text2.Text)
If m >= 2 And m <= n And m Mod 2 = 0 Then
y =
s = ""
For i = 1 To n * n
R = (i - 1) \ n + 1: C = (i - 1) Mod n + 1
If R <= y Or R > n - y Or C <= y Or C > n - y Then
b(i) = a(i)
Else
b(i) = ‘⑶
End If
s = s + b(i)
If i Mod n = 0 Then
List2.AddItem s
s = ""
End If
Next i
Else
List2.AddItem "输入有误"
End If
End Sub
a=[i for i in range(1,7)] b=[0]*6 head, tail=0,0 for i in range(1,7): cnt=1 while cnt<i: a[tail]=a[head] head=(head+1)%6 tail=(tail+1)%6 cnt+=1 b[a[head]- 1]=i head=(head+1)%6 |
执行该程序段后, b[5]的值为( )
试题篮