jcst.net
当前位置:首页 >> VB编程:随机产生10个0~100的整数 用选择法从小到... >>

VB编程:随机产生10个0~100的整数 用选择法从小到...

新建一个form1添加command1添加label1label1高度设的稍高一点,以显示数据。form代码视图中加入以下语句.Private Sub Command1_Click() '定义变量 Dim a(9) As Integer Dim i As Integer Dim r As Integer Dim t As Integer '产生随机数 Randomi...

Sub x() Dim arr(1 To 10) As Integer, i, j, k '产生随机数 For i = LBound(arr) To UBound(arr) arr(i) = Int(Rnd * 100) Next i MsgBox "随机生成的数据是:" & Join(arr, ",") '排序 For i = LBound(arr) To UBound(arr) - 1 k = i For j = ...

#include using namespace std;void main(){ int i, j, t, k; int a[10] = {8,9,6,7,4,5,2,0,1,-7}; for (i = 0; i < 10; i++) { k = i; for (j = i + 1; j < 10; j++) if (a[j] < a[k]) k = j; if (k != i) { t = a[k]; a[k] = a[i]; a[i] = t;...

#include#include#includeint main(){int i,j,k,t,a[10]; srand(time(0)); for(i=0;i

#include using namespace std; int main() { int a[100],n,x,i; while(cin>>n>>x) { for(i=0;i>a[i]; } if(x==0||x

急什么啊,百度上很多啊,随便搜一下就有了. Private Sub Command1_Click() Dim su(1 To 10) As Integer '定义数组 '产生随机数 For i = 1 To 10 su(i) = Rnd * 90 + 10 '产生10-100的数 Print su(i); Next Print '排序 '这样好像是选择排序吧,先...

If flag Then Exit For End If 这个什么意思了,这个不需要。 如果想经济一点,下面部分可再个条件句 temp = x(i) x(i) = x(imax) x(imax) = temp 如: if i imax then temp = x(i) x(i) = x(imax) x(imax) = temp end if

Dim A() As Integer '定义数组 ReDim A(1 To 15) '分配空间 For i = 1 To 15 A(i) = Fix(Rnd * 91 + 10) Next i '生成随机数 For i = 1 To 14 m = i For j = i + 1 To 15 If A(j) < A(m) Then m = j Next j q = A(m) A(m) = A(i) A(i) = q Next ...

Option Base 1 Dim a(20) Private Sub Form_Load() Randomize For i = 1 To 10 a(i) = Int(10 + 90 * Rnd) Next End Sub Private Sub Command1_Click() '选择排序法 For i = 1 To 9 For j = i + 1 To 10 If a(j) > a(i) Then t = a(i): a(i) = a...

网站首页 | 网站地图
All rights reserved Powered by www.jcst.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com