3个回答
展开全部
Dim i As Integer
Dim S(10) As Integer
Dim Max As Integer
For i = 0 To 9
Randomize
S(i) = Int(Rnd * 100) + 1
If i = 0 Then
Max = S(i)
ElseIf Max < S(i) Then
Max = S(i)
End If
Debug.Print Max & " " & S(i)
Next i
删除的我没有写,你自己扩展吧。。最大的数保存的MAX 中。S(i)随机数保存的数组
展开全部
int a[10],max,i; max=a[0]; for(i=0;i<10;i ) if(a[i]==max) a[i]=a[i 1];
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option Explicit
Private a(9) As Integer
Private iMaxIndex As Integer
Private Sub Command1_Click()
Dim i, j, k, iMax As Integer
Dim b As Boolean
Randomize
b = True
i = 0
iMax = 0
iMaxIndex = 0
Cls
Do While b
k = Int(Rnd * 100) + 1
For j = 0 To i
If k = a(j) Then Exit For
Next j
If j > i Then
a(i) = k
If k > iMax Then
iMax = k
iMaxIndex = i
End If
i = i + 1
b = (Not (i > 9))
Print k
End If
Loop
Print "最大:" & Str(iMax)
End Sub
Private Sub Command2_Click()
Dim i As Integer
a(iMaxIndex) = 0
For i = 0 To 9
Print a(i)
Next i
End Sub
Private a(9) As Integer
Private iMaxIndex As Integer
Private Sub Command1_Click()
Dim i, j, k, iMax As Integer
Dim b As Boolean
Randomize
b = True
i = 0
iMax = 0
iMaxIndex = 0
Cls
Do While b
k = Int(Rnd * 100) + 1
For j = 0 To i
If k = a(j) Then Exit For
Next j
If j > i Then
a(i) = k
If k > iMax Then
iMax = k
iMaxIndex = i
End If
i = i + 1
b = (Not (i > 9))
Print k
End If
Loop
Print "最大:" & Str(iMax)
End Sub
Private Sub Command2_Click()
Dim i As Integer
a(iMaxIndex) = 0
For i = 0 To 9
Print a(i)
Next i
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询