题库 高中信息

题干

在VB中,函数lnt(7.2)的值是(  )
A.-7.2B.7C.7.2D.8
上一题 下一题 0.99难度 选择题 更新时间:2019-08-11 04:22:51

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

同类题1

(加试题)异或的数学符号为“⊕”,其运算法则相当于不带进位的二进制加法: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

同类题5

小李与小王合作编写一个成绩统计的VB程序:小王编写一个过程,该过程从数据库读取某一指定科目的相关数据,存储在数组a中;小李编写一个过程,该过程依据数组a中的相关数据统计各班平均分。小李与小王约定的数组a各元素含义如图所示。

程序功能如下:在文本框text1中输入科目名称,单击“读取数据库”按钮command1,程序从数据库读取数据;单击“开始统计”按钮command2,程序进行统计处理,结果输出在列表框list1中。程序运行界面如下图所示。

数组元素

数组元素的含义

a(1)

存储班级数n

a(2)

从a(2)到a(n+1) 依次存储第1、2、…第n个班级人数

 

a(n+1)

a(n+2)

从a(n+2) 依次存储第1班每个学生的单科成绩、第2班每个学生的单科成绩、…第n班每个学生的单科成绩

 

实现上述功能的VB程序如下,请回答下列问题:
(1)根据程序运行界面中的数据及数组a各元素的含义,数组元素a(5)的值为________(填写数值)。
(2)分析程序,可知数据库的文件名为___________________
(3)请在划线处填入合适的代码。
Dim a(1 to 600) as integer    ‘数组大小满足处理要求
Private  sub  command1_click()
‘本过程由小王完成,从数据库读取指定科目的各相关数据,存储在数组a中

Dim conn As New ADODB.Conncction

Dim rs As New ADODB.Recordset

Conn ConncctionString=”provider=Microsoft.AC

A.OLEDB.12.0;data source=”+”Score.accdb”

Conn.Open

Set rs.ActiveConnection=conn

‘本过程的其他语句略

End sub
Private  sub  command2_click()
‘依据数组a中的相关数据统计各班级平均分

Dim i As Integer, j As Integer, n As Integer

Dim p As Integer, sum As Integer, aver As Single

______________________

p = n + 2

For i = 1 To n

sum = 0

For j = 1 To a(i + 1)

  ____________________
p = p + 1

Next j

aver = sum / a(i + 1)

list1.additemstr(i)+"   "+str(a(i+1))+"   "+str(aver)

Next i

End sub