比较十个数的大小

一·实验目的

实现十个数的大小比较,最终输出最大的一个数。

二·实验内容

在对象窗口划出一个command按钮,点击command按钮输入以下vb程序语言:

Private Sub Command1_Click()

Dim a As Integer

Dim b As Integer

Dim max As Integer

Dim c As Integer

Dim d As Integer

Dim f As Integer

Dim g As Integer

Dim h As Integer

Dim i As Integer

Dim j As Integer

a = 45

b = 78

c = 123

d= 136

e=98

f=456

g=32

h=76

i=57

j=145

If a > b Then

max = a

Else

max = b

End If

If c > max Then

max = c

End If

If d> max Then

max = d

End If

If e > max Then

max =e

End If

If f > max Then

max =f

End If

If g> max Then

max = g

End If

Ifh > max Then

max = h

End If

If i > max Then

max = i

End If

If j > max Then

max =j

End If

Print max

End Sub

点击运行即可。

但是,如果采用循环语句我这个程序就会出现问题。

采用循环与依据如下:

dim a as integer

dim b as integer

dim f(i) as integer

if a>b then

max=a

else

max=b

end if

for i=0 to 7=int (rnd*100)

if f(i)> max then

max=f(i)

end if

点击运行,却出现错误

三·心得体会

尽管出现了问题,但是我学会了开动脑筋解决问题。

四·遇到的问题及解决方法

从三个数的大小比较到十个数的大小比较,有一定的难度,没有想到用循环的方法,通过老师的提点,采用了循环,但是没有能够成功。

五·没有解决的问题

采用循环的方法但是没能够运行成功,并且,没能找到所出现的问题,望老师提点。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值