题库 高中信息

题干

退出当前For循环的代码为(   )
A.endB.exitC.subD.exit for
上一题 下一题 0.99难度 选择题 更新时间:2019-04-21 09:49:33

答案(点此获取答案解析)

同类题1

某班师生玩一个游戏,n(n 不超过 1000)个同学站成一圈,逆时针编号为 l - n,有两个老师 A 和 B,A 老师从 1 开始逆时针数 k 个同学,B 老师从 n 开始顺时针数 m 个同学(注意 A,B 老师可能数到同一个学生),被老师选中的 1 个或 2 个学生离开圈子,剩下的学生继续。
程序开始时在 Text1 中输入同学数 n,在 Text2 中输入 k 的值,在 Text3 中输入 m 的值,点击“开始” 按钮,在 label5 中显示依次出圈的学生编号。程序运行如图所示:

VB 程序如下,请将按要求答题:
Dim stu(1 To 1000) As Integer
Dim n As Integer
Private Sub Command1_Click()

Dim left, k, m As Integer

Dim stup1, stup2 As Integer

n = Val(Text1.Text)

k = Val(Text2.Text)

m = Val(Text3.Text)

        
stup1 = n: stup2 = 1
For i = 1 To n
stu(i) = i Next i
Do While left > 0
stup1 = teachount(stup1, 1, k)
stup2 =
Label5.Caption = Label5.Caption & " " & Str(stup1)
left = left - 1
If        Then
Label5.Caption = Label5.Caption & " " & Str(stup2)
left = left - 1
End If stu(stup1) = 0

stu(stup2) = 0

Loop

End Sub
'f=1 表示逆时针数 c 个,f=-1 表示顺时针数 c 个
Function teachount(ByVal p As Integer, ByVal f As Integer, ByVal c As Integer) As Integer
Do While c > 0
        
Do While stu(p) = 0

p = (p + f + n - 1) Mod n + 1

Loop

c = c - 1

Loop teachount = p
End Function
(1)加框处的语句有错误,请改正:______________________________________________ 
(2)请将①处的语句补充完整:______________________________________________
(3)请将②处的语句补充完整:______________________________________________
(4)请将③处的语句补充完整:______________________________________________

同类题5

(加试题)异或的数学符号为“⊕”,其运算法则相当于不带进位的二进制加法:0⊕0=0,1⊕0=1,0⊕1=1,1⊕1=0(即符号两侧数值相同时,计算结果为0;数值不同时为1)。
如果要对两个十进制数进行异或运算,可以按以下步骤进行:
①   先将要进行异或运算的两个十进制数分别转换为二进制;
②   对两个二进制数按位进行异或运算;例:(101101)2⊕(111)2=(101010)2
③   再把步骤②中的运算结果转换为十进制,该十进制数即为运算结果。
小明编写了一个VB程序来模拟上述运算过程,程序功能如下:在文本框Text1和Text2中分别输入要参加异或运算的十进制数,单击计算按钮Command1,程序对输入的两个数进行异或运算,并将运算结果显示在文本框Text3中,程序运行界面如图所示。

(1)通过以上关于异或运算的描述,可知10⊕6的结果是___________。
(2)实现上述功能的VB程序如下。请在划线处填入合适的代码。
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer
Dim a1 As String, b1 As String
Dim lena1 As Integer, lenb1 As Integer, i As Integer
Dim result As String
a = Val(Text1.Text)
b = Val(Text2.Text)
If a > b Then
c = a: a = b: b = c
End If
result = ""
a1 = DtoB(a): b1 = DtoB(b)
lena1 = Len(a1): lenb1 = Len(b1)
i = 1
Do While i <= lena1
If Mid(a1, lena1 - i + 1, 1) = Mid(b1, lenb1 - i + 1, 1) Then
result = "0" + result
Else
result = "1" + result
End If
i = i + 1
Loop
result =_____
Text3.Text = BtoD(result)
End Sub
Public Function DtoB(x As Integer) As String
Dim remainder As String
DtoB = ""
Do While x > 0
remainder = CStr(x Mod 2)  '如:CStr(3 Mod 2)的值为"1"
DtoB = remainder + DtoB
________  
Loop
End Function
Public Function BtoD(x As String) As Integer
Dim i As Integer
BtoD = 0
For i = 1 To Len(x)
BtoD =________+ Val(Mid(x, i, 1))
Next i
End Function