点击查看:2018年12月计算机二级VB冲刺练习题及答案汇总
1.以下程序段:
Private Sub Form_Load( )
Dim Nop As Integer, Op As String * 1
Num1 = 3
Num2 = 2
Nop = val(Inputbox("请输入1-4之间的整数"))
Select Case Nop
Case 1
Op = "+"
Result = Num1 + Num2
Case 2
Op = "-"
Result = Num1 - Num2
Case 3
Op = "×"
Result = Num1 * Num2
Case 4
Op = "÷"
Result = Num1 / Num2
End Select
Label1= Num1 & Op & Num2 & "=" & Result
End Sub
窗体运行后,输入2,则label1的标题显示结果为(B)(单)
A.3+2=5
B.3-2=1
C.3×2=6
D.3÷2=1.5
2.以下程序段:
Private Sub Form_Load( )
Dim Nop As Integer, Op As String * 1
Num1 = 3
Num2 = 2
Nop = val(Inputbox("请输入1-4之间的整数"))
Select Case Nop
Case 1
Op = "+"
Result = Num1 + Num2
Case 2
Op = "-"
Result = Num1 - Num2
Case 3
Op = "×"
Result = Num1 * Num2
Case 4
Op = "÷"
Result = Num1 / Num2
End Select
Label1= Num1 & Op & Num2 & "=" & Result
End Sub
窗体运行后,输入3,则label1的标题显示结果为(C)(单)
A.3+2=5
B.3-2=1
C.3×2=6
D.3÷2=1.5
3.以下程序段:
Private Sub Form_Load( )
Dim Nop As Integer, Op As String * 1
Num1 = 3
Num2 = 2
Nop = val(Inputbox("请输入1-4之间的整数"))
Select Case Nop
Case 1
Op = "+"
Result = Num1 + Num2
Case 2
Op = "-"
Result = Num1 - Num2
Case 3
Op = "×"
Result = Num1 * Num2
Case 4
Op = "÷"
Result = Num1 / Num2
End Select
Label1= Num1 & Op & Num2 & "=" & Result
End Sub
窗体运行后,输入4,则label1的标题显示结果为(D)(单)
A.3+2=5
B.3-2=1
C.3×2=6
D.3÷2=1.5
4.以下程序段的作用是(A)(单)
Private Sub Picture1_Click( )
Dim asci As Integer, i As Integer
i = 0
For asci = 32 To 126
Picture1.Print Tab(7 * i + 2); Chr(asci); "="; asci;
i = i + 1
If i = 7 Then i = 0: Picture1.Print
Next asci
A.打印ASCII码表,一行7个表达式
B.打印九九乘法表,一行7个表达式
C.打印ASCII码表,一行8个表达式
D.以上说法都不正确
5.我国现在人口有13亿,按人口增长0.8%计算,多少年后我国人口将超过26亿。
Private Sub Command1_Click( )
Dim x, n
x = Val(Text1)
n = 0
Do While 【x】<26
x = x * (1 + 0.008)
n = n + 1
Loop
Text2 = Str(n)
End Sub
6.以下程序的作用是(B)(单)
For i = 1 To 9
For j = 1 To 9
se = i & "×" & j & "=" & i * j
Picture1.Print Tab((j - 1) * 9 + 1); se;
Next j
Picture1.Print
Next i
A.打印ASCII码表
B.打印九九乘法表
C.打印加法表
D.以上说法都不正确
7.求自然数e的近似值,误差小于0.00001,近似公式为:e=1+1/1!+1/2!+1/3!+……+1/I!+……以下程序用来求自然数e。
Private Sub Form_Click( )
Dim I%, n&, t!, e!
E = 0 ' 存放累加和结果
I = 0 ' 计数器
n = 1 ' 存放阶乘的值
t = 1 ' 级数第I项值
Do While 【t>】 0.00001
e = e + t
I = I + 1
n = n * I
t = 1 / n
Loop
Print "计算了 "; I; " 项的和是 "; e
End Sub
8.求自然数e的近似值,误差小于0.00001,近似公式为:e=1+1/1!+1/2!+1/3!+……+1/I!+……以下程序用来求自然数e。
Private Sub Form_Click( )
Dim I%, n&, t!, e!
E = 0 ' 存放累加和结果
I = 0 ' 计数器
n = 1 ' 存放阶乘的值
t = 1 ' 级数第I项值
Do While t>0.00001
e = e + 【t】
I = I + 1
n = n * I
t = 1 / n
Loop
Print "计算了 "; I; " 项的和是 "; e
End Sub
9.求自然数e的近似值,误差小于0.00001,近似公式为:e=1+1/1!+1/2!+1/3!+……+1/I!+……以下程序用来求自然数e。
Private Sub Form_Click( )
Dim I%, n&, t!, e!
E = 0 ' 存放累加和结果
I = 0 ' 计数器
n = 1 ' 存放阶乘的值
t = 1 ' 级数第I项值
Do While t>0.00001
e = e + t
I = I + 1
n = n * 【I】
t = 1 / n
Loop
Print "计算了 "; I; "项的和是"; e
End Sub
10.以下程序是求最大公约数和最小公倍数的程序。
Private Sub Form_Click( )
Dim m1, n1, m, n, r As Integer
n1 = InputBox("输入自然数n", "输入数")
m1 = InputBox("输入自然数m", "输入数")
n = n1
m = m1
If m < n Then
t = m: m = n: n = t
End If
r = m Mod 【n】
Do While (r<>0)
m = n
n = r
r = m Mod n
Loop
Print "最大公约数=", n
Print "最小公倍数= ", m1 * n1 / n
End Sub
微信搜索"考试吧"了解更多考试资讯、下载备考资料
相关推荐: