《Visual Basic程序设计基础》教材习题参考答案

For j = 1 To i

Print Space(4 - Len(Trim(Str(a(i, j))))); Trim(Str(a(i, j))); Next j Print Next i Exit Sub

k: MsgBox \输入n值小于1或大于10,数组下标超界。\End Sub

第4章 函数与过程

一、判断题

1.× 2.√ 3.× 4.× 5.√ 6.× 7.× 8.√ 二、填空题

1.按地址传送 2.b() As Long 3.6 4.按值传递 5.按地址传递 6.Public x As Single 7.Static x As Integer 8.Form2.y

三、程序阅读题(写出下列程序的运行结果)

程序1. s = 2 程序2. 1 程序3. 1 1 2 1 1 2 1 2 2 2 2 3 s = 5 1 1 s = 9 1 2 1 1 3 3 1 1 4 6 4 1 四、程序填空题 1.(1)ByeVal

(2)k Mod i (3)k = k \\ i

(2)t = t * x

(4)Call pp(i)

2.(1)a() Aa Double (2)n-1 (3)a(j) < a(k) 3.(1)a() As Double, n As Integer 五、程序设计题

程序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 / n End Function

程序2.界面设计略,过程设计如下:

Private Sub ff(a() As Single, n As Integer) Dim i As Integer, x As Single For i = 1 To n \\ 2

x = a(n - i + 1): a(n - i + 1) = a(i): a(i) = x Next i End Sub

(3)f = s

程序3.界面设计略,过程设计如下:

Private Sub find(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

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4