《VB程序设计基础》习题答案

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

程序设计基础

P16 习题一

一,判断题1,错2,对3,错4,错5,6,7,对

二,单选题1,B 2,B 3,D 4,A 5,D 6,B 7,B 8,C 9,D

三, 程序设计题

5, Private Sub Command1_Click()

Form1.FontName = "宋体"

Form1.Print "中文字体宋体"

End Sub

Private Sub Command2_Click()

Form1.FontName = "楷体_GB2312"

Form1.Print "中文字体楷体"

End Sub

Private Sub Command3_Click()

Form1.FontName = "仿宋_GB2312"

Form1.Print "中文字体仿宋"

End Sub

P42 习题二

一,判断题

1,2,3,7,10,对

4,5,6,8,9,11,12,13,14 错

二,单选题

1,A 2,C 3,C 4,B 5,B

6,A 7,B 8,C 9,B 10,C

11,C 12,D 13,B 14,A 15,D

16,B 17,B 18,C 19,B 20,B 21,B 22,D 23,A 24,C 25,B 26,A 27,D 28,B

三,简答题

1. (1) 2 * Cos(alfa) * Sin(alfa/ ( 2 * a )

(2) Sqr( s*(s–a)*(s–b )*(s - c))

(3) ( A^2 + B*C*(X +Y)) / (A+B)

(4) ( 2* 3.14159*r +Exp(-5))* Log(x)

(5) 1/( x + 1/(y+1) )

(6) k / ( 1 + a * Exp(-b*x) )

(7) 5 + 6*x / ( 3 * (x^2-1) - 2*x )

(8) Sqr( y^3 + 3 * (a^2+b^2) / (x^2+y^2) )

2. (1) (a+b) Mod c (2)

Sqr(Abs(x))

(3) Int(x) + 1 (4) Int(Rnd

*101)+200

3. Private Sub Form_Click()

Dim a As Integer, b As Integer

Dim c As Integer, y As Long

a = InputBox("请输入a的值")

b = InputBox("请输入b的值")

c = InputBox("请输入c的值")

y = a ^ 2 + 2 * b ^ 2 + 2 * c ^ 2

Print " y = "; y

End Sub

4。(1) F (2)T (3) F (4) T

5 . (1)1<=x And x<12 (2)T+3<>V-2 And (T+V)>100

(3)(a+b) >= c or (a-c) <= c

(4)a>0 And Int(a)=a And b>0 And

Int(b)=b or a<0 And b<0

(5)x<=y Or x>=z

(6)a=0 And b<>0 or a<>0 And b=0 四, 编程题

1. Private Sub Form_Click()

Dim a As Integer, b As Integer

Dim c As Integer, y As Single

a = InputBox("请输入正整数a的值")

b = InputBox("请输入正整数b的值")

c = InputBox("请输入正整数c的值")

y = (a + b + c) / 3

Print " 平均值y = "; y

End Sub

2. Private Sub Form_Click()

Dim r As Integer, s As Single

Const Pi = 3.14159

r = InputBox("输入圆半径", "输入", 10)

s = Pi * r * r

MsgBox "圆面积Area =" & Str(s)

End Sub

P78 习题三

一,1,A 2,B 3,B 4,A 5,C

二,1,37,55,64,28,19

2,y=KIGECA

3, 1

121

12321

1234321

123454321

12345654321

4,cHINA!

三,1,t As Double

s=1

Abs(t)>=1e-5

s=s+t

2, s+c

-1

s

3, m=n

m To n

Sum=Sum+j

Sum=i

四,1,

Private Sub Form_Click()

Dim x As Single, f As Single

x = InputBox("输入x: ")

If x < -5 Then

f = 3 * x * x + 2 * x - 1

ElseIf x <= 5 Then

f = x * Sin(x) + 2 ^ x

Else

f = Sqr(x - 5) + Log(x) / Log(10) End If

Label1.Caption = f

End Sub

2.

Private Sub Form_Click()

Dim i As Integer, flag As Integer

Dim t As Double, y As Double

y = 0

flag = 1

t = 0.5

i = 1

While Abs(t) >= 0.00001

t = 1 / i / (i + 1)

y = y + flag * t

flag = -flag

i = i + 1

Wend

Print "y="; y

End Sub

Y=0.386289385475669

3.

Private Sub Form_Click()

Dim n As Integer, i As Integer, flag As Integer, s As Single, t As Integer

n = InputBox("请输入n的值:")

sum = 0

t = 1

flag = -1

For i = 1 To n

flag = -flag

t = t * i

s = s + flag * i / t

Next i

Print "s="; s

End Sub

4.

Private Sub Command1_Click()

For i = 1 To 9

For j = 1 To i

Print i; "*"; j; "="; i * j;

Next j

Print

Next i

End Sub

5.

Private Sub Form_Click()

For i = 1 To 5

Print Tab(6 - i);

For j = 1 To 2 * i - 1

Print "*";

Next j

Print

Next i

For i = 4 To 1 Step -1

Print Tab(6 - i);

For j = 1 To 2 * i - 1

相关文档
最新文档