收藏 分销(赏)

浙江省高校计算机等级考试复习资料——二级VB语言(答案).doc

上传人:人****来 文档编号:4330253 上传时间:2024-09-06 格式:DOC 页数:22 大小:281.51KB 下载积分:10 金币
下载 相关 举报
浙江省高校计算机等级考试复习资料——二级VB语言(答案).doc_第1页
第1页 / 共22页
浙江省高校计算机等级考试复习资料——二级VB语言(答案).doc_第2页
第2页 / 共22页


点击查看更多>>
资源描述
《浙江省高校计算机等级考试复习资料——二级VB语言》答案 目 录 2009年春浙江省高等学校计算机等级考试二级VB参考答案 2 2008年秋浙江省高等学校计算机等级考试二级VB参考答案 3 2008年春浙江省高等学校计算机等级考试参考答案(二级 VB) 4 2007年秋浙江省高等学校计算机等级考试参考答案(二级 VB) 5 2007年春浙江省高等学校计算机等级考试参考答案(二级 VB) 7 VB上机考试程序调试题样题(填空)参考答案 7 VB上机考试程序调试题样题(改错)参考答案 7 VB上机考试程序设计题样题参考答案 9 2009年春浙江省高等学校计算机等级考试二级VB参考答案 试题1~试题6 请在各小题正确选项的对应位置处填“√”(每小题3分,共72分) A B C D A B C D (1) √ (13) √ (2) √ (14) √ (3) √ (15) √ (4) √ (16) √ (5) √ (17) √ (6) √ (18) √ (7) √ (19) √ (8) √ (20) √ (9) √ (21) √ (10) √ (22) √ (11) √ (23) √ (12) √ (24) √ 试题7(28分) Dim a() As Double, ave As Double, n As Integer, seit As Double Private Sub Command1_Click() '输入数据n以及n个数。 小计 10分 Dim i As Integer ' 1 分 n = Inputbox("n=") ' 2 分 Redim a(n) ' 3 分 For i = 1 To n ' 4 分 a(i) = InputBox("a(" & i & ")=") Next i End Sub Private Sub Command2_Click() '计算、显示平均值。 小计 7分 Dim i As Integer ' 1 分 For i = 1 To n ' 4 分 ave = ave + a(i)/n Next i Text1.Text = ave ' 2 分 End Sub Private Sub Command3_Click() '计算、显示标准差。 小计 11分 Dim i As Integer ' 1 分 For i = 1 To n ' 5 分 seit = seit + (a(i) - ave) ^2 Next i seit = sqr(seit) / (n - 1) ' 3 分 Tetx2.Text = seit ' 2 分 End Sub 2008年秋浙江省高等学校计算机等级考试二级VB参考答案 试题1~试题6 请在各小题正确选项的对应位置处填“√”(每小题3分,共72分) A B C D A B C D (1) √ (13) √ (2) √ (14) √ (3) √ (15) √ (4) √ (16) √ (5) √ (17) √ (6) √ (18) √ (7) √ (19) √ (8) √ (20) √ (9) √ (21) √ (10) √ (22) √ (11) √ (23) √ (12) √ (24) √ 试题7(28分) 编程,按Command1后用通用对话框确定待输入的文件(格式如下,各行中四个数据分别表示学生姓名以及三门功课成绩),将其中三门课成绩均及格的学生信息按同样的格式输出到文件"e:\score.txt"。 "张三",77,86,93 "李四",77,86,93 ...... Private Sub Command1_Click() ' 声明变量 Dim name As String,k1 As Integer, k2 As Integer, k3 As Integer (2分) ' 用控件CommonDialog1选择文件 CommonDialog1.Action =1 (2分) ' 打开所选文件用于读数据,打开文件e:\score.txt用于写数据 Open CommonDialog1.FileName For Input As #1 (2分) Open "e:\score.txt" For OutPut As #2 (2分) ' 读文件中数据并处理 Do While Not Eof(1) (18分) Input #1, name,k1,k2,k3 循环结构6分 If k1>=60 And k2>=60 And k3>=60 Then _ Input 4分 Write #1,name,k1,k2,k3 条件 4分 Loop Write# 4分(Print#扣2分 Close #1: Close #2 (2分) End Sub 2008年春浙江省高等学校计算机等级考试参考答案(二级 VB) 试题1~试题6 请在各小题正确选项的对应位置处填“√”(每小题3分,共72分) A B C D A B C D (1) √ (13) √ (2) √ (14) √ (3) √ (15) √ (4) √ (16) √ (5) √ (17) √ (6) √ (18) √ (7) √ (19) √ (8) √ (20) √ (9) √ (21) √ (10) √ (22) √ (11) √ (23) √ (12) √ (24) √ 试题7(28分) 编程,按Command1可输入有10个实数的数组,调用函数f求他们的平均值V,然后输出其中与V之差的绝对值为最小的那个数组元素。 请将答卷上函数过程f(包括形参列表)、事件过程Command1补充完整。 Private Function f( b() As Single, n As Integer ) As Single '2分 Dim i As Integer '1分 For i = 1 To n '5分 f = f + b(i) Next i f = f / n '2分 End Function Private Sub Command1_Click() Dim a(10) As Single, i As Integer, v As Single, x As Single, d As Single '输入数据(3分) For i = 1 To 10 a(i) = InputBox("a(" & i & ")=") Next i '计算平均值v(3分) v = f(a, 10) '将与v之差的绝对值为最小的那个数组元素赋值给x。 x = a(1): d = Abs(a(1) - v) '2分 For i = 2 To 10 If Abs(a(i) - v) < d Then d = Abs(a(i) - v) '绝对值2分,其他6分 x = a(i) End If Next i Print x '2分 End Sub 2007年秋浙江省高等学校计算机等级考试参考答案(二级 VB) 试题1~试题6请在各小题正确选项的对应位置处填“√”(每小题3分,共72分) A B C D A B C D (1) √ (13) √ (2) √ (14) √ (3) √ (15) √ (4) √ (16) √ (5) √ (17) √ (6) √ (18) √ (7) √ (19) √ (8) √ (20) √ (9) √ (21) √ (10) √ (22) √ (11) √ (23) √ (12) √ (24) √ 试题7(28分) Dim a() As Single, n As Integer Private Sub Form_Load() Command1.Caption = "数据输入" (2分) Command2.Caption = "计算" (2分) End Sub Private Sub Command1_Click() '数据输入 Dim i As Integer (2分) n = Text1.Text (2分) ReDim a(n) (3分) For i = 1 To n a(i) = InputBox("") (5分) Next i End Sub Private Sub Command2_Click() Dim y As Single, i As Integer, x As Single (1分) x = Text2.Text (1分) y = a(1) (1分) For i = 2 To n y = y + a(i) * x ^ (i - 1) (7分) Next i Label3.Caption = y (2分) End Sub 2007年春浙江省高等学校计算机等级考试参考答案(二级 VB) 试题1~6 (每小题3分) ⑴ B ⑵ A ⑶ D ⑷ C ⑸ D ⑹ C ⑺ B ⑻ A ⑼ A ⑽ B ⑾ B ⑿ D ⒀ A ⒁ A ⒂ D ⒃ B ⒄ D ⒅ C ⒆ C ⒇ B (21)C (22)A (23)A (24)D 试题7 (28分) Private Function sum(Byval n As Integer) As Integer sum=0: n=Abs(n) while n>0 sum = sum + n mod 10: n=n\10 Wend End Function Private Sub Command1_Click() Dim a(10) As Integer, b(10) As Integer, i As Integer For i = 1 To 10 a(i) = InputBox("a(" & i & ")=" ): b(i) = sum(a(i)) Next i For i=1 To 8: Printf a(i); " "; :Next i Print For i=1 To 8: Printf b(i); " "; :Next i End Sub VB上机考试程序调试题样题(填空)参考答案 [题1] 1. dalt>0 2. dalt=0 3. Sqr(-dalt) [题2] 1. start = Space(21 - i) 2. Count = 19 - 2 * i 3. Form1.Print start; 4. Form1.Print [题3] 1. 5 2. num 3. Trim(i); [题4] 1.number(i) 2.n as integer 3.number=number*10+7 [题5] 1. 1 2. -1 3. x=(x+1)*2 [题6] 1. 2 2. b = False 3. k = k + 1 4. b 或 b = True [题7] 1.do while x<4 or x mod 2<>0 2.if isprime(i) and isprime(x-i) then 3.isprime=true 4.if x mod I=0 then [题8] 1. n+1 2. n Mod 3=1 and n Mod 5=1 and n Mod 7=1 3. While countN<5 [题9] 1. Not isLeapYear(year) 2. y Mod 4 <> 0 3. y Mod 100 = 0 4. y Mod 400 <> 0 [题10] 1.trim(str(i)) 2.trim(str(i^2)) 3.x1=right(x2,len(x1)) [题11] 1. i\100 2. i mod 10 3.i=hundred^3+ten^3+one^3 [题12] 1. i,n 2.if i=s then 3.for I=2 to x-1或for i=2 to x\2 4.a(k)=i [题13] 1. s = 1 2. Do While s < 1E+16 3. i = i + 1 [题14] 1. s < 1000 2. x 3. n + 1 4. n - 2 [题15] 1.sign=-1 2.19 3.sign=-sign [题16] 1.temp=1 2.temp 3.nfactor(i) 4.sum [题17] 1. 1 To Len(a) 2. n + fact(p) 3. fact = y [题18] 1.len(oldsen) 2.lastchar=" " 3.mid(oldsen,i,1) 4.ucase(char) [题19] 1. salary(i) 2. temp - hundred * 100 3. temp 4. totalsalary + salary(i) [题20] 1.Len(str1) 2.length-1 3.mid(str1,I,2) 4.sum=0 VB上机考试程序调试题样题(改错)参考答案 [题1] 1.for i=9 to 1 step –1 2. Form1.Print Trim(Str(i)); 3. End Sub [题2] 1.for two=1 to n-one 2.if one+two*2+five*5=60 then 3.next two 4.next one [题3] 1.dim k as single 2.for i=1 to 100 step2 3.k=-1/(i+1) [题4] 1.cmn=nfactor(m)/(nfactor(n)*nfactor(m-n)) 2.nfactor=temp 3.End function [题5] 1.length=len(str1) 2. strright=mid(str1,k,1) 3. strleft=mid(str1,length-k+1,1) 4. If strleft <>strright Then [题6] 1.case is>r 2.Loop until times>5 或 Loop While times <= 5 3.Form1.print “正确答案为”& str(r) [题7] 1.n=len(Hex) 2.temp=Mid(Hex,n-i,1) 3.Form1.print Hex + “转换为十进制数为” + str(Dec) 或 Form1.print Hex & “转换为十进制数为” & Dec 或Form1.print Hex ;“转换为十进制数为” ; Dec [题8] 1. For i = 0 To 9 2. n = Int(Rnd * 90) + 10 3. MsgBox "偶数个数:" & count [题9] 1.a(i)=int(Rnd*100) 2.p=a(i) mod 10 3.x(p)=x(p)+1 4.Form1.print “个位数为”+str(p)+”共”+str(x(i)) + "个" [题10] 1.Swap a(j),a(i) 2.Loop while i<n 3.for j=1 to i-1 4.Public Sub Swap(a as integer,b as integer) [题11] 1.If ave(Line_no)<ave(i) then 2.Line_no=i 3.a(1,j)=a(Line_no,j) 4.sum=sum+a(i,j) [题12] 1.If i<>j and i<>6-j then 2.Form1.print a(I,j);space(3); 3.form1.print :form1.print VB上机考试程序设计题样题参考答案 1. 新建一个工程,完成“加法器”程序的设计。 参考答案: Private Sub Command1_Click() Text3.Text = Str(Val(Text1.Text) + Val(Text2.Text)) End Sub Private Sub Command2_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text1.SetFocus End Sub Private Sub Form_Load() Form1.Caption = "加法器" '文本框清空 Text1.Text = "" Text2.Text = "" Text3.Text = "" '设置文本框右对齐 Text1.Alignment = 1 Text2.Alignment = 1 Text3.Alignment = 1 '屏蔽对Text3的编辑 Text3.Locked = True Label1.Caption = "+" Command1.Caption = "=" Command2.Caption = "清空" End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) If (KeyAscii < 48) Or (KeyAscii > 57) Then KeyAscii = 0 End If End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) If (KeyAscii < 48) Or (KeyAscii > 57) Then KeyAscii = 0 End If End Sub 2. 新建一个工程,完成“健康称”程序的设计。具体要求如下: 参考答案: Private Sub Command1_Click() Dim bzh As Single bzh = Val(Text1.Text) - 105 If Val(Text2.Text) > bzh * 1.1 Then Label5.Caption = "偏胖,注意饮食" ElseIf Val(Text2.Text) < bzh * 0.9 Then Label5.Caption = "偏瘦,增加营养" Else Label5.Caption = "正常,继续保持" End If End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then '输入非数字 KeyAscii=0 End If End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then '输入非数字 KeyAscii=0 End If End Sub 3. 新建一个工程,完成应用程序的设计,具体要求如下: 参考答案: Private Sub Command1_Click() If Form1.WindowState = 0 Then Command1.Caption = "最小化(&B)" Form1.WindowState = 2 Command1.Left = (Form1.Width - Command1.Width) / 2 Command1.Top = (Form1.ScaleHeight - Command1.Height) / 2 Else Form1.WindowState = 0 Command1.Caption = "最大化(&L)" Command1.Left = (Form1.Width - Command1.Width) / 2 Command1.Top = (Form1.ScaleHeight - Command1.Height) / 2 End If End Sub 4. 新建一个工程,完成“判断质数”应用程序的设计。具体要求如下: 参考答案: Private Sub Command1_Click() Dim n As Integer, i As Integer n = Text1.Text For i = 2 To Sqr(n) If n Mod i = 0 Then Exit For Next i If i > Sqr(n) Then Label2.Caption = Label2.Caption + "是质数" Else Label2.Caption = Label2.Caption + "不是质数" End If End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0 MsgBox("输入的不是数字, 无法计算") End If End Sub 5. 新建一个工程,完成“计算平均成绩”应用程序的设计。具体要求如下: 参考答案: Private Sub Text1_Change() Text4.Text = Str((Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text)) / 3) End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0 n = MsgBox("输入的不是数字, 无法计算") End If End Sub Private Sub Text2_Change() Text4.Text = Str((Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text)) / 3) End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0 n = MsgBox("输入的不是数字, 无法计算") End If End Sub Private Sub Text3_Change() Text4.Text = Str((Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text)) / 3) End Sub Private Sub Text3_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0 n = MsgBox("输入的不是数字, 无法计算") End If End Sub Private Sub Text4_Change() Text4.Locked = True End Sub 6. 新建一个工程,完成“收款计算”程序的设计。具体要求如下: 参考答案: Private Sub Command1_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text1.setfocus End Sub Private Sub Command2_Click() Text3.Text = Str(Val(Text1.Text) * Val(Text2.Text)) End Sub 7. 新建一个工程,完成“编辑”程序的设计。具体要求如下: 参考答案: Private Sub Command1_Click() '将文本框选中的内容复制到剪粘板中 Clipboard.SetText Text1.SelText End Sub Private Sub Command2_Click() Clipboard.SetText Text1.SelText Text1.SelText = "" End Sub Private Sub Command3_Click() Text1.SelText = Clipboard.GetText() '将要粘贴的内容复制到光标所在处 End Sub Private Sub Command4_Click() '删除 Text1.seltext=”” End Sub Private Sub Form_Load() Form1.Caption = "编辑" Form1.BorderStyle = 1 Command1.Caption = "复制" Command2.Caption = "剪切" Command3.Caption = "粘贴" Command4.Caption = "删除" End Sub 8. 新建一个工程,完成“密码检验”程序的设计。具体要求如下: 参考答案: Private Sub Command1_Click() End End Sub Private Sub Form_Load() Label2.Visible = False Label2.AutoSize = True Text1.PasswordChar = "*" End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) Static times As Integer '统计第几次输入密码 ' 按回车键后进行密码检验 If KeyAscii = 13 Then If Text1.Text = "1234567" Then Label2.Caption = "欢迎光临!" Label2.Visible = True Else If times < 2 Then Label2.Caption = "密码不符,请再输入一遍!" Label2.Visible = True Text1.Text = "" Else Label2.Caption = "非法用户,请退出程序!" Text1.Text = "" Text1.Enabled = False End If End If times = times + 1 End If End Sub 9. 新建一个工程,完成应用程序的设计。具体要求如下: 参考答案: Private Sub Command1_Click() If Text1.Text = Text2.Text And Text1.Text = "admin" Then If Text3.Text = Text4.Text And Text3.Text <> "" Then MsgBox ("密码修改成功") Else MsgBox ("请重新输入新密码") End If Else MsgBox ("请重新输入用户名或密码") End If End Sub Private Sub Command2_Click() End End Sub Private Sub Form_Load() Text1.TabIndex = 0 Text2.TabIndex = 1 Text3.TabIndex = 2 Text4.TabIndex = 3 Command1.TabIndex = 4 Command2.TabIndex = 5 End Sub 10. 新建一个工程,完成应用程序的设计。具体要求如下: 参考答案: Private Sub Command1_Click() Dim ss As String For i = 1 To Len(aa(Text1.Text)) ss = aa(Text1.Text) Print Mid(ss, i, 1) Next i Command1.Enabled = False End Sub Private Sub Command2_Click() End End Sub Function aa(ss As String) As String Dim x() As Integer Dim temp As Integer ReDim x(Len(ss)) For i = 1 To Len(ss) x(i) = Asc(Mid(ss, i, 1)) Next
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服