mdsk.net
当前位置:首页 >> VB数组找最大最小值问题. >>

VB数组找最大最小值问题.

很简单 for i=0 to 5 a(i)=inputbox("输入任意数",找最值) next i max=a(0) max_j=0 for j=1 to 5 if(a(j)>max) then max=a(j) max_j=j endif next j print max max_j 这个就是的 上面的>改成

代码及注释如下: sub main() dim a(0 to 99) as integer, amin as integer, i as integer, imin as integer x = 65536'定义变量x为一个比数组中最大值还要大的数 for i = 0 to 99'假设数组元素个数为100个 if x > a(i) then x= a(i)‘如果x大于...

vb没有max和min函数,需要自己编写 Private Sub Command1_Click() Dim arr(1 To 100) As Integer Randomize For i = 1 To 100 arr(i) = Int(Rnd * 10000) Print Format(arr(i), "@@@@ "); If i Mod 10 = 0 Then Print Next Print Print "最大值=...

1、遍历数组进行比较查找即可。 2、vb6示例代码: Option Explicit Private Sub Command1_Click() Randomize Timer Dim a(9) As Integer, i As Integer Dim x, Fp As Integer, Zp As Integer For i = 0 To 9 '模拟生成一个随机数组 a(i) = 50 - ...

Private Sub Form_Click() Form1.AutoRedraw = True Dim A() Dim I As Integer, J As Integer, N As Integer Dim MinG As Integer, MaxG As Integer A = Array(0, 0, 3, 4, 12, 11, 34, 34, 34, 34) For I = 0 To UBound(A) - 1 For J = I To UB...

题目不是交代了要用循环,但是你没用啊,没用循环是做不了这件事的。 Dim x(1 To 10) As Integer, max As Integer, min As Integer,i As Integer Label1.Caption = "" For i = 1 To 10 x(i) = Val(InputBox("输入第“ & i & "个整数", "输入整数"...

dim str as string dim str1 as new str dim max,i,n as integer max=0 n=0 'n用于记录位置 '随机分配两位数的数组 for i=0 to str1.length str1[i]=Sint(rnd()*10+90) end for '对数组进行排序 for i=0 to str1.length if max

你是不是应该对最大值和最小值赋初值(比如把 r(1) 赋给最大值和最小值)呢?不然最小值默认初始值是‘0’,后面的判断就不起作用了。你可以加个断点试试,他们的初始值是多少。。。

Dim d() As Integer Dim i As Integer Dim MyMax As Integer Dim n As Integer n = Val(InputBox("输入n!")) ReDim d(n) As Integer For i = 1 To n d(i) = Val(InputBox("输入第" & i & "个数!")) Next i MyMax = d(1) For i = 2 To n If d(i)...

二楼有简便方法……此方法作为参照_(:зゝ∠)_ 写个函数丢模块里 题目描述有点不清楚,大致代码如下 使用方法:返回值=MaxNum(数组名称) 如:Dim a(1 to 5) as integer:b=MaxNum(a) Public Function MaxNum(sz() As Integer) As IntegerDim i As Inte...

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