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

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

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...

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 ...

Dim a(1 To 10) As Integer, zc As Integer For i = 1 To 10 a(i) = Int(Rnd * 101) '0~100一共101个数,从零开始,所以是int(rnd*101+0),+0省略 Print a(i); '打印原始数据 Next i Print For i = 1 To 10 For j = 1 To 9 If a(j + 1) < a(j) T...

//#include "stdafx.h"//vc++6.0加上这一行. #include "stdio.h" #include "time.h" #include "stdlib.h" int main(void){ int nDec[100],i,j,k; srand((unsigned)time(NULL)); for(i=0;i

急什么啊,百度上很多啊,随便搜一下就有了. 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 '排序 '这样好像是选择排序吧,先...

选择法: Private Sub Form_Click() Dim i%, j%, a%(1 To 10) Randomize For i = 1 To 10 a(i) = Int(101 * Rnd) Next i For i = 1 To 9 k = i For j = i + 1 To 10 If a(j) < a(k) Then k = j Next j If k i Then t = a(i): a(i) = a(k): a(k) ...

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 #include main() { int num[25]; int tmp; unsigned char i,j; for(i=0;i

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

#include #include #include int random() //产生随机数10-99范围的随机数 { int num; num = rand()%100; return num; } void selectsort(int k[],int n) //选择法排序 { int i,j,max,t; for(i=0;i

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