vb实验报告答案全(2)(1)

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

实验一问答题:
1、答:
常见的有visual Basic、C++、Java、SQL。

用途特点:(参考课本4-5页)
2、答:
代码是一行或几行命令。

程序是针对某个任务编写的有序代码的集合。

软件是程序和文档的集合。

它们的关系是:代码 < 程序 < 软件
3、答:
面向对象程序设计中的每一个对象都应该能够接受数据、处理数据并将数据传达给其它对象,因此它们都可以被看作一个小型的“机器”,即对象。

它能够让人们更简单地设计并维护程序,使得程序更加便于分析、设计、理解。

4、答:
参考课本第9页
5、答:
类——是创建对象实例的模板, 包含了创建对象的属性描述和行为特征的定义。

对象——是类的一个实例,继承了类的属性、方法。

控件——是具有图形界面的对象,它同样具有属性、方法、事件,是用来设计用户界面的重要元素。

属性——是对象的性质,用来描述和反应对象特征的参数。

事件——响应对象的动作,它发生在用户与程序交互时。

如单击控件、鼠标移动、键盘按下。

过程——指附在该对象上的程序代码,是事件的处理程序。

6、答:
参考课本12页到17页。

实验二问答题:
1、答
通用属性有:Caption标题、Enabled可用性、Visible可见性、ForeColor前景颜色、BackColor背景颜色等。

2、答
标签label是用来显示信息的,不具有输入功能。

属性有Caption、BackStyle、Alignment、BorderStyle、AutoSize。

文本框用来输入、输出数据,编辑文本。

属性有Text、 Maxlength、MultiLine、 ScrollBars、 Locked 、 PassWord 。

3、答
结果为:标签里显示一个“abc”,图片框里显示3行“欢迎您”。

4、答
要保存2次,分别是工程文件.vbp和窗体文件.frm。

实验一:
一、选择
1.D
2.D
3.B
4.A
5.B
6.C
7.CD
8.D
9.D10.编程机制是C、设计方式是B
11.A12.D13.D14.C15.A
二、填空
1.windows
2. 中断
3.工具箱
4.代码
5.分类
6.form2.show
7. 出现语法错误
8. 错
9. 事件10. 面向对象11. 工程文件结构及各文件名12. 工程13. 设计程序代码14.
双击窗体15.vb的安装文件夹16.属性17.方法18.font 19. form_load() 20.对象
1.Private Sub Command1_Click()
Print Sqr(8), 8 ^ (1 / 3)
End Sub
2.Private Sub Command1_Click()
For i = 100 To 110
Print Sqr(i)
Next i
End Sub
3.Private Sub Form_Load()
Print " 郑州大学在前进!"
End Sub
4. Private Sub label_click()
Print
Label.caption=”蓝天白云绿水青山”
End sub
实验二:
一、选择
1.B
2.C
3.B
4.C
5.C
6.C
7.B
8.B
9.D10.A
11.C12.C13.C14.B15.A
16.C17.B18.D19.C20.C
二、填空
1. Form_Click()
2. Interval、500
3..vbp .frm
4.left top Height、Width twip
5.picture
6.load
7. locked
8. font Alignment
9. GotFocus() LostFocus() 10. 属性窗口程序代码
1.Private Sub Command1_Click()
Label3 = Val(Text1) * Val(Text2)
Private Sub Command2_Click()
Label3 = Val(Text1) / Val(Text2)
End Sub
2.Private Sub Command1_Click()
Picture1.Visible = True
Picture1.Picture = LoadPicture("d:\tu1.jpg") End Sub
Private Sub Command2_Click()
Picture1.Visible = True
Picture1.Picture = LoadPicture("d:\tu2.jpg") End Sub
Private Sub Command3_Click()
Picture1.Visible = False
'也可以改为:Picture1.Picture = LoadPicture("") End Sub
3.Private Sub Command1_Click()
Label3 = Val(Text1) * Val(Text2) End Sub
4.Private Sub Command1_Click() Text2 = Text1
End Sub
Private Sub Command2_Click() Text1 = ""
Text2 = ""
End Sub
Private Sub Form_Load() Command1.Visible = False Command2.Visible = False
End Sub
Private Sub Text1_Change() Command1.Visible = True Command2.Visible = True
End Sub
5.Private Sub Form_Load()
Image1.Picture = LoadPicture("d:\tu3.jpg")
End Sub
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Image1.Left = Int(Rnd * (Form1.ScaleWidth - Image1.Width)) Image1.Top = Int(Rnd * (Form1.ScaleHeight - Image1.Height)) End
实验三:
一、选择
1.A
2.BC
3.BC
4.A
5.A
6.A
7.BCD
8.D
9.B10.B 11.B
二、判断题
不合法的变量:3. 4. 5. 6. 8. 10. 11. 14.15. 16.
三、
1、abs(x+y)
2. (3+x*y)^2
3. (-b+sqr(b^2-4*a*c))/(2*a)
4.sin(30*3.14/180)+exp(2)
四、
1. int(rnd* 71+20) 或int(rnd* 71)+20
2. x<0 and y>0 or x>0 and y<0 或者x*y<0
3. x mod 3=0 or x mod 7=0
或x/3=x\3 or x/7=x\7
4. x>=10 and x<20
5. x>="A" and x<="Z"
6. left(s,3) 或mid(s,1,3)
操作题:
2.Private Sub Command1_Click()
Dim n%
n = Abs(Val(Text1))
Label2 = Format(n ^ 2, "#.000") & Space(2) & Format(Sqr(n), "#.000") & Space(2) & Format(n ^ 3, "#.000") & Space(2) & Format(n ^ (1 / 3), "#.000")
'上句的输出也可以用下面的print方式:
' Print Format(n ^ 2, "#.000"); Spc(2); Format(Sqr(n), "#.000"); Spc(2); Format(n ^ 3, "#.000"); Spc(2); Format(n ^ (1 / 3), "#.000")
End Sub
3.Private Sub Command1_Click()
Dim x%, y%
x = Int(Rnd * 900 + 100)
Print "产生的随机数:"; x
y = (x Mod 10) * 100 + (x \ 10 Mod 10) * 10 + x \ 100
Print "反序数:"; Format(y, "000")
End Sub
Private Sub Command2_Click()
Dim x%, y As String
x = Int(Rnd * 900 + 100)
Print "产生的随机数:"; x
y = Trim(Str(x))
Print "反序数:" & Right(y, 1) & Mid(y, 2, 1) & Left(y, 1)
End Sub
4.Private Sub Command1_Click()
Dim m%, n%
Randomize
m = Val(Text1): n = Val(Text2)
x = Int(Rnd * (n - m) + m)
y = Int(Rnd * (n - m) + m)
z = Int(Rnd * (n - m) + m)
Label3 = m & "到" & n & "之间的3个随机数为: " & x & Space(3) & y & Space(3) & z
End Sub
5.Private Sub Command1_Click()
Label1.Caption = Date
End Sub
Private Sub Command2_Click()
Label2.Caption = Time
End Sub
Private Sub Command3_Click()
Label3.Caption = WeekdayName(Weekday(Date))
End Sub
实验四:
一、选择
1.C
2.D
3. C
4.D
5.A
6.D
7.B
8.B
9.A10.C
二、填空
1. 48.71E-01, -4.8712
2. 关系、逻辑、算术
3. 900,100,mid(s,2,1)
4.m、1,2,3 、print m & "月是第二季度"、end select
三、程序结果
1. X=4 y=13
2. 10
操作题:
1.方法一:Private Sub Command1_Click()
x = InputBox("请输入弧度数值", "弧度转换", 0)
xx = Val(x)
a = x * 180 / 3.14
aa = Int(a)
b = (a - aa) * 60
bb = Int(b)
c = (b - bb) * 60
cc = Format(c, "#.000")
MsgBox "弧度" & x & "转换为" & aa & "度" & bb & "分" & cc & "秒" End Sub
方法二:Option Explicit
Private Sub Command1_Click()
Dim x!, a!, aa%, b!, bb%, c!, cc$
x = Val(Text1)
a = x * 180 / 3.14
aa = Int(a)
b = (a - aa) * 60
bb = Int(b)
c = (b - bb) * 60
cc = Format(c, "#.000")
Label2 = "弧度" & Text1 & "转换为" & aa & "度" & bb & "分" & cc & "秒"
End Sub
2.Private Sub Command1_Click()
Dim x%
x = Val(Text1)
If x / 400 = x \ 400 Or x Mod 4 = 0 And x Mod 100 <> 0 Then
Label2 = Text1 & "年是闰年"
Else
Label2 = Text1 & "年不是闰年"
End If
End Sub
3.Private Sub Command1_Click()
Dim x%, y%, z%
x = InputBox("输入第一个数")
y = InputBox("输入第二个数")
z = InputBox("输入第三个数")
Print "输入的数是:"; x; y; z
If x > y Then t = x: x = y: y = t
If y > z Then t = y: y = z: z = t
If x > y Then t = x: x = y: y = t
Print "排序结果是:"; x; y; z
End Sub
4.方法一:Private Sub Command1_Click() x = Val(InputBox("请输入上网时间:")) If x <> -1 Then
Select Case x
Case Is < 10
fei = 25
Case 10 To 50
fei = x * 2
Case 50 To 100
fei = x * 1.5
fei = x * 1
End Select
MsgBox "上网费用为:" & fei & "元" End If
End Sub
Private Sub Command2_Click()
End
End Sub
方法二:Private Sub Command1_Click() Do
x = Val(InputBox("请输入上网时间:", , -1)) If x <> -1 Then
Select Case x
Case Is < 10
fei = 25
Case 10 To 50
fei = x * 2
Case 50 To 100
fei = x * 1.5
Case Is >= 100
End Select
zongfei = zongfei & Space(3) & fei MsgBox zongfei, , "上网费用为"
Else
Exit Do
End If
Loop
End Sub
Private Sub Command2_Click()
End
End Sub
实验五
一、选择
B C B A C
二、填空
(1)for x=2 to 10
s*(1-1/x)
(2) 1 t>1E-6
(3) j t
(4) 5 11 5
1.Private Sub Command1_Click()
For n = 1 To 100
s = s + n
Next n
Print s
End Sub
Private Sub Command2_Click()
n = 1
Do While n <= 100
s = s + n
n = n + 1
Loop
Print s
End Sub
2.Private Sub Command1_Click()
For i = 0 To 20
For j = 0 To 33
If i * 5 + j * 3 + 1 / 3 * (100 - i - j) = 100 Then Print i, j, 100 - i - j Next j
Next i
End Sub
3.Private Sub Command1_Click()
n = 0
Do
If n Mod 2 = 1 And n Mod 3 = 2 And n Mod 5 = 4 And n Mod 6 = 5 And n Mod 7 = 0 Then Exit Do
n = n + 1
Loop
Print n
End Sub
4.'已知x,y,z分别是0~9中的一个数,求x,y,z的值,使得xxz+yzz=532. Private Sub Command1_Click()
Dim x%, y%, z%, i%, j%
For x = 0 To 9
For y = 0 To 9
For z = 0 To 9
If (x * 100 + x * 10 + z) + (y * 100 + z * 10 + z) = 532 Then Print x, y, z Next
Next
Next
End Sub
Private Sub Command2_Click()
For x = 0 To 9
For y = 0 To 9
For z = 0 To 9
If Val(x & x & z) + Val(y & z & z) = 532 Then Print x; y; z Next
Next
Next
End Sub
5.Private Sub Command1_Click()
x = Val(Text1)
y = x * 4
n = 0
Do While x <= y
x = x * (1 + 0.1)
n = n + 1
Loop
Print x, n
End Sub
6.Private Sub Command1_Click()
n = Val(InputBox("输入计算到第几项:", , 0))
For i = 1 To n
s = s + (-1) ^ (i + 1) * i
Next
Print n, s
End Sub
Private Sub Command2_Click()
n = Val(InputBox("输入计算到第几项:", , 0))
p = 1
For i = 1 To n
s = s + p * i
p = -p
Next
Print n, s
End Sub
7.'s=(0+1)+(0+1+2)+(0+1+2+3)+(0+1+2+3+4)+……(0+1+2+3+4+……n) Private Sub Command1_Click()
Dim n%, s%
n = Val(InputBox("输入计算到第几项:", , 0))
s = 0: t = 0
For i = 1 To n
t = t + i
s = s + t
Next i
Print s
End Sub
Private Sub Command2_Click()
Dim n%, s%
n = Val(InputBox("输入计算到第几项:", , 0)) s = 0: t = 0
For i = 1 To n
t = 0
For j = 1 To i
t = t + j
Next
s = s + t
Next
Print s
End Sub
8.Private Sub Command1_Click()
Dim s As Double, pi As Double
n = 1: s = 0
Do While 1 / (2 * n - 1) >= 0.0001 '也可以是Do Until 1 / (2 * n - 1)< 0.0001
s = s + (-1) ^ (n + 1) * 1 / (2 * n - 1)
n = n + 1
Loop
pi = 4 * s
Print pi
End Sub
9.'5-9:输出所有的“水仙花数”.
'所谓的“水仙花数”是指一个3位数,其各位数字的立方和等于该数本身。

'例如153是一个水仙花数,因为153=1^3+5^3+3^3
Private Sub Command1_Click()
For n = 100 To 999
k = Format(n) '或者k = Trim(Str(n))
If n = Left(k, 1) ^ 3 + Mid(k, 2, 1) ^ 3 + Right(k, 1) ^ 3 Then Print n
Next
End Sub
Private Sub Command2_Click()
For x = 1 To 9
For y = 0 To 9
For z = 0 To 9
n = x * 100 + y * 10 + z
s = x ^ 3 + y ^ 3 + z ^ 3
If n = s Then Print n
Next
Next
Next
End Sub
10.'第10题的改造题-----求100至999之间的最大三个素数(的平均值) Private Sub Command1_Click()
For n = 999 To 100 Step -1
For i = 2 To n - 1
If n Mod i = 0 Then Exit For
Next i
If i = n Then
Print n
s = s + n
k = k + 1
End If
If k = 3 Then Exit For
Next n
Print s / 3
End Sub
11.'随机产生20个(50,100)范围内的随机整数,
'显示他们当中的最大值、最小值和平均值
Private Sub Command1_Click()
s = 0: Max = 0: Min = 1000
For i = 1 To 20
x = Int(Rnd * 49 + 51) '(50,100)即为[51,100),Int(Rnd * (100-51) + 51)
Print x;
s = s + x
If x > Max Then Max = x
If x < Min Then Min = x
Next i
aver = s / 20
Print
Print "max="; Max, "min="; Min, "aver="; aver
End Sub
12.Private Sub Command1_Click()
For i = 1 To 4
Print Tab(10 - i);
For j = 1 To 2 * i - 1
If j <= i Then
Print Format(j);
Else
Print Format(2 * i - j); End If
Next
Print
Next
End Sub
Private Sub Command2_Click() For i = 1 To 4
Print Tab(10 - i);
For j = 1 To 2 * i - 1
Print Chr(64 + i);
Next
Print
Next
End Sub
Private Sub Command3_Click()
For i = 1 To 4
Print Tab(10 - i);
For j = 1 To 2 * i - 1
If j Mod 2 = 1 Then
Print "*";
Else
Print "+";
End If
Next
Print
Next
End Sub
实验六:
一、选择
1.B
2.C
3. C
4.C
5.D
6.D
7.D
8.D
9.C10.A
二、填空
1. 求n!
2. 求1+2+3+…+n
3. 判断n是否素数
4.利用冒泡法对数组排序
5.求第n项Fib数列的值
6.求m,n的最大公约数、最小公倍数
操作题:
Private Sub Command7_Click() '第1题Dim i%, a%(1 To 10), max%, min%, avg!
max = 0: min = 100: avg = 0
For i = 1 To 10
a(i) = Int(Rnd * 51 + 50)
Print a(i);
If a(i) > max Then max = a(i)
If a(i) < min Then min = a(i)
s = s + a(i)
Next i
Print
Print "--------------------"
Print max, min, s / 10
End Sub
Private Sub Command8_Click() '第2题Dim s%(1 To 20), a%, b%, c%, d%, e%
For i = 1 To 20
s(i) = Int(Rnd * 101) '随机产生一个数
Print s(i);
If i Mod 5 = 0 Then Print
Next i
'a = 0: b = 0: c = 0: d = 0: e = 0
'若在dim中定义了是整型,则默认初始值为0,那么这里5个赋值就都可省略
For i = 1 To 20
Select Case s(i)
Case 90 To 100
a = a + 1
Case 80 To 89 '使用"is>=80"也可,如后面的。

b = b + 1
Case Is >= 70
c = c + 1
Case Is >= 60
d = d + 1
Case Else
e = e + 1
End Select
Rem 上面的select语句也可以换成多分支If..ElseIf..Elseif..End If 语句来实现分类统计的功能。

Next i
Print "优秀="; a; "良好="; b; "中="; c; "及格="; d; "不及格="; e End Sub
Private Sub Command1_Click() '第3题
Dim a(1 To 10) As Integer, i%, j%
For i = 1 To 10
a(i) = Int(Rnd * 50 + 1)
Print a(i);
Next i
Print
n = 10
'For i = 1 To n - 1 选择法排序
' Max = i
' For j = i + 1 To n
' If a(j) < a(Max) Then Max = j
' Next j
' t = a(i): a(i) = a(Max): a(Max) = t
'Next i
For i = 1 To n - 1 '冒泡法排序
For j = n To i + 1 Step -1
If a(j) > a(j - 1) Then
t = a(j): a(j) = a(j - 1): a(j - 1) = t
End If
Next j
Next i
Print "-----------排序之后--------"
For i = 1 To 10
Print a(i);
Next i
Print
End Sub
Private Sub Command2_Click() '第4题(因为两循环的起始、终止一样,所以可以合并入一个)
Dim a(1 To 20) As Integer, i%
For i = 1 To 20 '产生数组
a(i) = Int(Rnd * 101 + 1)
Next i
For i = 1 To 20 '打印数组
'Print a(i);
'If i Mod 5 = 0 Then Print
If i Mod 5 = 0 Then Print a(i) Else Print a(i); '可以用这一句代替上面两句
Next i
End Sub
Private Sub Command3_Click() '第5题
Dim a%(1 To 9), b%(1 To 3, 1 To 3), i%, j%
For i = 1 To 9
a(i) = Int(Rnd * 100)
Print a(i);
Next i
Print
'For i = 1 To 3
' For j = 1 To 3
' b(i, j) = a((i - 1) * 3 + j)
' Print b(i, j);
' Next j
' Print
'Next i
'上面的这个双重循环也可以用下面程序段代替:k = 1
For i = 1 To 3
For j = 1 To 3
b(i, j) = a(k)
Print b(i, j);
k = k + 1
Next j
Print
Next i
End Sub
Private Sub Command4_Click() '第6题和第7题Dim a() As Integer, i%
n = InputBox("n")
ReDim a(1 To n, 1 To n)
For i = 1 To n
For j = 1 To n
a(i, j) = Int(Rnd * 100)
Print a(i, j);
Next j
Print
Next i
'对角线赋值为1 (第7题)
For i = 1 To n
For j = 1 To n
If (i = j) Or (i + j = n + 1) Then a(i, j) = 1 Else a(i, j) = 0
Print a(i, j);
Next j
Print
Next i
End Sub
Private Sub Command5_Click() '第8和9题
Dim a(), i%, j%, m%, n%
m = InputBox("M")
n = InputBox("n")
ReDim a(1 To m, 1 To n)
For i = 1 To m
For j = 1 To n
a(i, j) = Int(Rnd * 100)
Print Tab(j * 5); a(i, j);
Next j
Print
Next i
max = a(1, 1): imax = 1: jmax = 1
For i = 1 To m
For j = 1 To n
If a(i, j) > max Then
max = a(i, j)
imax = i
jmax = j
End If
Next j
Next i
Print "--------------"
Print "max="; max, "imax="; imax, "jmax="; jmax
Print
'第9题,添加一列
ReDim Preserve a(1 To m, 1 To n + 1)
For i = 1 To m
a(i, n + 1) = 0
For j = 1 To n '计算第i行的各列和,放入它的第n+1列里
a(i, n + 1) = a(i, n + 1) + a(i, j) Next j
Next i
For i = 1 To m
For j = 1 To n + 1
Print Tab(j * 5); a(i, j);
Next j
Print
Next i
End Sub
Private Sub Command6_Click() '第10题Dim n%, a%(), i%
n = InputBox("n")
ReDim a(1 To n)
Print "-----初值-----------------"
For i = 1 To n '赋值
a(i) = Int(Rnd * 21 - 10)
Print a(i);
If i Mod 5 = 0 Then Print
Next i
Print
For i = 1 To n - 1 '将相同的值得数组元素赋值为-100 If a(i) <> -100 Then
For j = i + 1 To n
If a(j) = a(i) Then a(j) = -100
Next j
End If
Next i
Print "-----重复的值赋值为-100----------"
For i = 1 To n
Print a(i);
If i Mod 5 = 0 Then Print
Next i
Print
Print "-----删除掉重复的值------------"
'重新排列-100以外的数到1~k
k = 0
For i = 1 To n
If a(i) <> -100 Then
k = k + 1
a(k) = a(i)
End If
Next i
'打印原数组中有效的前k个
ReDim Preserve a(1 To k)
For i = 1 To k
Print a(i);
If i Mod 5 = 0 Then Print
Next i
End Sub
实验七:
一、选择
1.C
2.C
3. D
4.A
5.B
6.D
7.AB
8.A
9.A10.A
二、填空
1. 求1到n的乘积
2. 求1到n的和
3. 如果n是素数则函数值返回1,否则返回0
4. 利用冒泡法对数组a进行小到大排序
5. 利用递归算法求斐波那契数列第n项的值。

6. 求m,n的最大公约数、最小公倍数。

操作题:
1. Function jc(x)
t = 1
For i = 1 To x
t = t * i
Next i
jc = t
End Function
Private Sub Command1_Click()
For i = 1 To 10
s = s + jc(i)
Next i
Print s
End Sub
2. Private Sub Command1_Click()
Dim n, f As Integer
n = Val(InputBox("输入任意一个数"))
sushu n, f
Print n; "的标志是"; f
End Sub
Public Sub sushu(n, flag)
flag = 1
For i = 2 To n - 1
If n Mod i = 0 Then flag = 0: Exit For
Next i
End Sub
3. Private Sub Command1_Click()
n = InputBox("任意输入一个数")
If hws(n) = True Then Print n; "是" Else Print n; "不是" End Sub
Function hws(x) As Boolean
Print x
hws = True
For i = 1 To Len(x) \ 2
If Mid(x, i, 1) <> Mid(x, Len(x) + 1 - i, 1) Then
hws = False
Exit For
End If
Next i
End Function
4. Rem 利用函数过程求n!/(m!.(n-m)!) Function jc(x)
t = 1
For i = 1 To x
t = t * i
Next i
jc = t
End Function
Private Sub Command1_Click()
n = Val(InputBox("输入N"))
m = Val(InputBox("输入M"))
Print "函数法结果为"; jc(n) / (jc(m) * jc(n - m)) End Sub
Rem 利用子程序过程求n!/(m!.(n-m)!)
Sub fact1(ByVal x As Integer, t)
t = 1
For i = 1 To x
t = t * i
Next i
End Sub
Private Sub Command2_Click()
n = Val(InputBox("n="))
m = Val(InputBox("m="))
fact1 n, nt
fact1 m, mt
fact1 n - m, zt
Print "子过程结果"; nt / (mt * zt)
End Sub
5. Private Sub Command1_Click()
Dim n#
n = InputBox("输入一个实数")
Print n; "的数字之和为"; shuzihe(n)
End Sub
Function shuzihe(x#)
Dim c$, k$, s%, i%
c = Format(x)
For i = 1 To Len(c)
k = Mid(c, i, 1)
If k >= "0" And k <= "9" Then s = s + Val(k)
Next i
shuzihe = s
End Function
6. Private Sub Command1_Click()
Dim n$
n = InputBox("输入任意字符串") Print n; "中的数字个数为"; szgs(n) End Sub
Function szgs(x$)
For i = 1 To Len(x)
k = Mid(x, i, 1)
If k >= "0" And k <= "9" Then s = s + 1 Next i
szgs = s
End Function
7. Private Sub Command1_Click()
Dim m%, n%
m = InputBox("输入第一个数")
n = InputBox("输入第二个数")
Print m, n
gysgbs m, n, p
Print "最大公约数为"; n Print "最小公倍数为"; p End Sub
Public Sub gysgbs(x, y, z) Dim r As Integer
t = x * y
Do
r = x Mod y
If r = 0 Then Exit Do x = y
y = r
Loop
z = t / y
End Sub。

相关文档
最新文档