gaizaoahe.com
当前位置:首页>>关于vb随机生成10个数字的资料>>

vb随机生成10个数字

Dim a(10) As Integer Dim s As StringPrivate Sub Command1_Click() Dim i, j, min, t As Integer For i = 1 To 9 min = i For j = i + 1 To 10 If a(j) < a(min) Then min = j Next j t = a(i) a(i) = a(min) a(min) = t Next i s = "" For i = 1 To 10 s = s & " " & a(i)

代码如下 产生10个随机数字 a 累加值bPrivate Sub Command1_Click()Dim i As Integer, a As Integer, b As IntegerFor i = 1 To 10 a = Int(Rnd * 100) Print a b = b + aNext iPrint bEnd Sub

程序基本正确.随机生成十个数字(1-100之间的整数)应该是:1+Int(Rnd * 100)

Option Base 1 Dim i As Integer Dim j As Integer Dim a(10) As Integer Private Sub Command1_Click()'1、-----------------------------------'a(i) = Int(Rnd(1) * 100 + 1) '这里不对因为你使用了Option Base 1语句所以a()数组的最小下标是1,你这里i并没

添加listbox1,label1,command1Public Class Form1 Dim N(10) As Integer '生成随机数 Private Sub CreatRand() Dim I As Integer Dim Strarr As String Strarr = "" ListBox1.Items.Clear() Dim R As New System.Random For I = 0 To 9 N(I) = R.Next(30

Dim A(1 To 10) As Integer Private Sub 查找_Click() Dim N As Integer N = Val(Text1.Text) Dim sMin As Integer, sMax As Integer sMin = 1: sMax = 10 Do i = (sMin + sMax) / 2 If A(i) = N Then MsgBox N & "在数组中存在" Exit Sub ElseIf A(i) > N

添加listbox1,label1,command1 public class form1 dim n(10) as integer '生成随机数 private sub creatrand() dim i as integer dim strarr as string strarr = "" listbox1.items.clear() dim r as new system.random for i = 0 to 9 n(i) = r.next(30, 100) listbox1.

var str="" for i as integer =0 to 9 Randomize() Dim r As int= Cint(Rnd() * 1) str&=Cstr(r) next textbox1.text=str var sz=str.ToCharArray().Max() var wz=str.IndexOf(sz) MsgBox("最大数字" & sz & "在" & wz)

randomizefor i = 1 to 10a(i)=int(rnd*(50))+1next i

private sub form_load()me.autoredraw = truedim rndnum(10) as integer, tochange as integer'产生十个两位随机数,并输出me.print "原始的十个数是:"for i = 1 to 10randomizerndnum(i) = int(rnd * 51) + 0me.print rndnum(i)next ifor i = 1 to 10 for j

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