题库 高中信息

题干

VB表达式: Sqr(Abs(Int(-8.2)))+ 32 mod 10 \ 3的结果是
A.5B.4C.3D.2
上一题 下一题 0.99难度 选择题 更新时间:2019-11-27 12:16:47

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

同类题3

用VB设计一个模拟选手得分程序,在文本框Text1中输入裁判人数(人数大于2),然后点击Command1按钮,在List1中产生70到100的随机数为裁判的打分,去除一个最高分,去除一个最低分,取其他裁判打分的平均分作为最终得分显示在文本框Text2中,运行效果如图所示。

(1)若要在程序运行时,修改窗体显示的标题为“得分计算”,则下面语句可行的是__________。
(单选,填字母:A.Command1.Caption=“得分计算”/B.Form1.Name=“得分计算”/C.Form1.Text=“得分计算”/
A.Form1.Caption=“得分计算”)
(2)实现上述功能的VB程序如下,请在划线处填入合适的代码。
Private Sub Command1_Click()
Dim n As Integer   '裁判人数
Dim max As Integer, min As Integer, sum As Integer
Dim AveScore As Single  '存储最终得分
n = Val(Text1.Text): sum = 0
If n <= 2 Then MsgBox ("输入数据要大于2,请重新输入!")
If n > 2 Then
List1.Clear
Randomize
score = Int(Rnd() * 31) + 70
List1.AddItem Str(score)
_______________________ ' ①
max = score
min = score
For i = 2 To n
score = Int(Rnd() * 31) + 70
List1.AddItem Str(score)
If score > max Then max = score
If score < min Then min = score
sum = sum + score
Next i
AveScore = ______________________ '②
Text2.Text = Str(AveScore)
End If
End Sub
(3)若要将最终得分保留一位小数(四舍五入),下列代码可行的是______________________。
A.AveScore=int(AveScore+0.5)
B.AveScore=int(AveScore*10+0.5)/10
C.AveScore=int(AveScore*100+0.5)/100

同类题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