下册前七章习题答案_第1页
下册前七章习题答案_第2页
下册前七章习题答案_第3页
下册前七章习题答案_第4页
下册前七章习题答案_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、习题参考答案习题一一 判断题1 2 3 4 5× 6 7× 8 9 10二 选择题1C 2D 3C 4B 5A 6D 7A 8B 9C 10D三 程序设计题1(略)2界面设计(略) 代码设计如下:Private Sub Command1_Click() Text2.Text = Text1.TextEnd SubPrivate Sub Command2_Click() EndEnd Sub3界面设计(略)Private Sub Command1_Click() Label1.Visible = FalseEnd SubPrivate Sub Command2_Click()

2、 Label1.Visible = TrueEnd Sub习题二一、判断题1. 2.× 3.× 4. 5.× 6.二、单选题1.B 2.D 3.B 4.A 5.B 6.D 7.B 8.B 9.C 10.B 11.C 12.C 13.C 14.B 15.C 16.A 17.C 18.C 19.B 20.D三、程序设计题1参考程序代码如下:Private Sub Form_click() Dim a As Integer, b As Integer, c As Integer Dim t As Integer, s As Integer a = Val(InputBo

3、x("a=", "输入三角形的三条边") b = InputBox("b=", "输入三角形的三条边") c = InputBox("c=", "输入三角形的三条边") t = (a + b + c) / 2 s = Sqr(t * (t - a) * (t - b) * (t - c) MsgBox "三角形的面积:" + Str(s)End Sub2参考程序代码如下:Private Sub Form_click() Dim r As Integer,

4、s As Integer Const pi = 3.14159 r = Val(InputBox("r=", "请输入圆的半径") l = 2 * pi * r s = pi * r 2 Print "r=" r, "l=" l, "s=" sEnd Sub习题三一、选择题1C 2A 3D 4C 5C 6D二、程序阅读题(写出下列程序的运行结果)程序1.-3 3程序2.Bcddef程序3.15 0 4程序455程序5.s=24程序6AAA 三、程序填空题1(1)q * i (2)s + p *

5、i / q (3)Next i2(1)t + m (2)m = m + 2 (3)m <= 393(1)Len(Text1.Text) (2)d & c (3)Text2.Text = d四、程序设计题1界面设计略,过程设计如下:Private Sub Form_Click() Dim x As Integer, y As Integer, z As Integer Dim t As Integer x = InputBox("请输入x的值:") y = InputBox("请输入y的值:") z = InputBox("请输入z

6、的值:") If x < y Then t = x: x = y: y = t If x < z Then t = x: x = z: z = t If y < z Then t = y: y = z: z = t Print x; y; zEnd Sub2界面设计略,过程设计如下:Private Sub Form_Click() Dim x As Single, y As Single x = InputBox("请输入x的值:") If x > 5 Then y = x - 5 ElseIf x >= 1 Then y = x *

7、 x ElseIf x > 0 Then y = Sqr(x) Else y = 0 End If Print yEnd Sub3界面设计略,过程设计如下:Private Sub Form_Click() Dim x As Single, n As Integer, d As Single Dim y As Single, s As Single, t As Single x = InputBox("输入x的值") n = InputBox("输入多项式的项数") s = 1 y = x For i = 2 To n d = 1 t = 1 For

8、 k = 1 To 2 * i - 1 '求多项式中一项的值 d = d * k '一项的分母 t = t * x '一项的分子 Next k s = (-1) * s '改变多项式的符号 y = y + s * t / d '求多项式之和 Next i Print "sinx=" yEnd Sub4界面设计略,过程设计如下:Private Sub Form_Click() Dim x As Single, s As Single, t As Single Dim i As Integer, n As Integer x = Inpu

9、tBox("请输入x的值:") n = InputBox("请输入n的值:") t = x / 2: s = t For i = 3 To n t = t * x / i s = s + t Next i Print sEnd Sub习题四一、选择题1A2B3C4C G A C D E二、程序阅读题(写出下列程序的运行结果)程序118程序213程序31 4 9 16 25程序4三、程序填空题1(1)10 + Int(Rnd * 90) (2)i + 1 To 30 (3)a(i)=a(j) (4)a(i) Mod 2 = 12(1)Int(Rnd * 9

10、0) + 10 (2)arr(i) > 50 (3)sum + arr(i) 3(1)ReDim a(n, n) As Integer (2)Int(n / 2 + 0.5)(3)a(j, k) = i (4)Print四、程序设计题1界面设计略,过程设计如下:Private Sub Form_Click() Dim a(2, 5), b(5, 3), c(2, 3) For k = 1 To 2 For i = 1 To 5 a(k, i) = k + 1 Print a(k, i); Next i Print Next k Print For k = 1 To 5 For i = 1

11、 To 3 b(k, i) = k + 1 Print b(k, i); Next i Print Next k Print For k = 1 To 2 For i = 1 To 3 For j = 1 To 5 c(k, i) = c(k, i) + a(k, j) * b(j, i) Next j Print c(k, i), Next i Print Next kEnd Sub2界面设计略,过程设计如下:Private Sub Form_Click() Dim a(10) As Integer, i As Integer Dim t As Integer For i = 1 To 10

12、 a(i) = Int(Rnd * 21) + 20 Print a(i); Next i Print t = a(10) For i = 10 To 2 Step -1 a(i) = a(i - 1) Next i a(1) = t For i = 1 To 10 Print a(i); Next iEnd Sub3. 界面设计略。过程设计如下:Private Sub Form_Click() Dim might As Integer, low As Integer, high As Integer Dim i As Integer, j As Integer, flag As Boolea

13、n Dim key As Integer Dim a(10) As Integer flag = False For i = 1 To 10 a(i) = Val(InputBox("输入有序的数:", "数据输入") Next i key = Val(InputBox("输入要检索的数据:") low = 1: high = 10 might = (low + high) / 2 Do While low <= high If key = a(might) Then Print "查找的数据为:" a(mi

14、ght); "位于第" might; "位" flag = True Exit Do End If If key > a(might) Then low = might + 1 Else high = might - 1 End If might = (low + high) / 2 Loop If flag = False Then Print "查无此数"End Sub习题五一、选择题1A B2A3D4C5D二、程序阅读题(写出下列程序的运行结果)程序125 50 75程序216 0三、程序填空题1(1)p = True (

15、2)m Mod i = 0 (3)i - 2, i2(1)a() Aa Double (2)n-1 (3)a(j) < a(k) 3(1)n / 2 (2)b(n - i + 1) (3)a, 10 四、程序设计题1界面设计略,过程设计如下:Private Function fsum(x() As Double, n As Integer) As Double Dim i As Integer For i = 1 To n fsum = fsum + x(i) Next i fsum = fsum / nEnd Function2界面设计略,过程设计如下:Private Sub find

16、(x() As Single, m As byte, n As Byte, _xmax As Single,ki As Byte,kj As Byte) xmax = x(1,1): ki = 1: kj = 1 For i = 1 To m For j = 1 To n If Abs(x(i, j) > Abs(xmax) Then xmax = x(i, j): ki = i: kj = j Next j, i End Sub习题六一、 选择题1、A 2、A 3、A 4、C 5、B 6、C 7、B 8、D 9、D 10、C 11、B 12、A 13、D 14、B 15、B 16、C

17、17、B 18、B 19、D 20、C 21、C 22、B 23、B 24、D 25、D 26、C 27、D 28、A 29、A 30、D 二、 程序阅读题1、(1)PasswordChar (2)Ucase(Text1.Text)2、(1)KeyAscii = 13 (2)n = Len(x) (3)y = y + Mid(x, i, 1) (4)Text2.Text =y3、(1)List1.ListCount (2)List1.RemoveItem i (3)i=i+14、(1)Change() (2)Hscroll1.Value (3)Scroll (4)Hscroll1_ Chang

18、e三、 程序设计题1、 过程设计如下:Private Sub Form_Load() For i = 0 To 2 Command1(i).Enabled = False Next iEnd SubPrivate Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If Text1.SelLength > 0 Then Command1(0).Enabled = True Command1(1).Enabled = True Else Command1(0).Enabled =

19、False Command1(1).Enabled = False End IfEnd SubPrivate Sub Command1_Click(Index As Integer) Command1(0).Enabled = False Command1(1).Enabled = False Select Case Index Case 0 Clipboard.Clear Clipboard.SetText Text1.SelText Command1(2).Enabled = True Case 1 Clipboard.Clear Clipboard.SetText Text1.SelTe

20、xt Text1.SelText = "" Command1(2).Enabled = True Case 2 Text1.SelText = Clipboard.GetText Command1(2).Enabled = False End SelectEnd Sub2、 过程设计如下:Private Sub Command1_Click() Text1.SetFocus Text1.Text = "" Text2.Text = "" Text3.Text = "" For i = 0 To 3 Option1(

21、i).Value = False Next iEnd SubPublic Sub Option1_Click(Index As Integer) Label1.Caption = Option1(Index).Caption Select Case Index Case 0 Text3.Text = Val(Text1.Text) + Val(Text2.Text) Case 1 Text3.Text = Val(Text1.Text) - Val(Text2.Text) Case 2 Text3.Text = Val(Text1.Text) * Val(Text2.Text) Case 3

22、If Val(Text2.Text) <> 0 Then Text3.Text = Val(Text1.Text) / Val(Text2.Text) Else Text3.Text = "" Text2.SetFocus Text2.SelStart = 0 Text2.SelLength = 1 MsgBox "除数不能为0,请重输或选择其他的运算符" Option1(3).Value = False End If End SelectEnd Sub3、 过程设计如下:Private Sub Command1_Click() If Lis

23、t1.ListIndex = -1 Then MsgBox "请先选择" Else Combo1.AddItem List1.Text List1.RemoveItem List1.ListIndex End IfEnd SubPrivate Sub Command2_Click() If Combo1.ListIndex = -1 Then MsgBox "请先选择" Else List1.AddItem Combo1.Text Combo1.RemoveItem Combo1.ListIndex End IfEnd SubPrivate Sub Co

24、mmand3_Click() Do While List1.ListCount <> 0 Combo1.AddItem List1.List(0) List1.RemoveItem 0 LoopEnd Sub4、 过程设计如下:Private Sub Form_Load() Timer1.Interval = 200 Label1.Caption = "欢迎使用VB" Label1.Left = -Label1.WidthEnd SubPrivate Sub Timer1_Timer() If Label1.Left <= Form1.Width Then Label1.Left = Label1.Left + 100 Else Label1.Left = -Label1.Width End IfEnd Sub习题七一、 选择题1、A

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论