题目
1、随机产生10个10-99范围内的整数,分别用选择和冒泡法将数据按从大到小递减的顺序排列,并显示排序结果
提问时间:2021-02-12
答案
Private Sub Form_click()
Dim A(1 To 10)
Randomize
For I = 1 To 10
A(I) = Int(Rnd * 90) + 10
Next I
For I = 1 To 9 '选择法
p = I
For J = I + 1 To 10
If A(J) < A(I) Then
p = J
End If
Next J
tem = A(I)
A(I) = A(p)
A(p) = tem
Next I
For I = 1 To 10
A(I) = A(11 - I)
Next I
For I = 1 To 9 '冒泡法
For J = 1 To 10 - I
If A(J) > A(J + 1) Then
tem = A(I)
A(I) = A(p)
A(p) = tem
End If
Next J
Next I
For I = 1 To 10
A(I) = A(11 - I)
Next I
End Sub
这就好了 你试试哦
Dim A(1 To 10)
Randomize
For I = 1 To 10
A(I) = Int(Rnd * 90) + 10
Next I
For I = 1 To 9 '选择法
p = I
For J = I + 1 To 10
If A(J) < A(I) Then
p = J
End If
Next J
tem = A(I)
A(I) = A(p)
A(p) = tem
Next I
For I = 1 To 10
A(I) = A(11 - I)
Next I
For I = 1 To 9 '冒泡法
For J = 1 To 10 - I
If A(J) > A(J + 1) Then
tem = A(I)
A(I) = A(p)
A(p) = tem
End If
Next J
Next I
For I = 1 To 10
A(I) = A(11 - I)
Next I
End Sub
这就好了 你试试哦
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
热门考点
- 1在括号里填上近、反义词
- 2设Sn为等差数列{an}的前n项和,Tn为等比数列{bn}的前n项积. (1)求证:数列S10,S20-S10,S30-S20成等差数列,并给出更一般的结论(只要求给出结论,不必证明); (2)若T1
- 3已知函数f(x)=x3+bx2+cx+d在区间[-1,2]上是减函数,那么b+c( ) A.有最大值152 B.有最大值-152 C.有最小值152 D.有最小值-152
- 4从0,1,2,3,4,5,6 中选出三个不同的数作为二次函数y=ax 2 +bx+c 的系数a、b、c,且满足 a>b,这样可得不同的二次函数的个数为( )(A)195 (B)120 (C)105 (
- 5语文高手进!急呀急呀
- 618.Her parents___her to study hard for a bright futureA.coax B.advise C.force D.urge
- 7保护鸟类的措施快.10好要,最少5条
- 8高等数学中若函数fx在(a,b)内可导且fx的导数>0,则函数fx在(a,b)内单调递增,为什么是开区间?
- 9双曲线的渐近线方程是3x+2y=0,则该双曲线的离心率为
- 10The train has gone You two ___ on time A should come B must have come C ought to have come