VB编程:随机产生10个100以内的数,并存放在A数组中,求A数组中的最大数及其所对应的下标。
1个回答
展开全部
Dim a(10) As Single
Randomize
maxi = 1
a(1) = Rnd * 100
Print a(1);
Max = a(1)
For i = 2 To 10
a(i) = Rnd * 100
Print a(i);
If a(i) > Max Then Max = a(i): maxi = i
Next i
Print
Print Max, maxi
23.79419 85.81158 83.98183 80.55384 86.33952 76.22736 3.579193 74.22757 72.92087 38.6757
86.33952 5
3.619021 36.96209 58.65529 72.15845 64.65067 81.91889 64.62961 56.70132 28.6246 62.1895
81.91889 6
Randomize
maxi = 1
a(1) = Rnd * 100
Print a(1);
Max = a(1)
For i = 2 To 10
a(i) = Rnd * 100
Print a(i);
If a(i) > Max Then Max = a(i): maxi = i
Next i
Print Max, maxi
23.79419 85.81158 83.98183 80.55384 86.33952 76.22736 3.579193 74.22757 72.92087 38.6757
86.33952 5
3.619021 36.96209 58.65529 72.15845 64.65067 81.91889 64.62961 56.70132 28.6246 62.1895
81.91889 6
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询