1樓:尤在尤存
一樓有問題.
dim a(19) as double
for i=0 to 19
a(i)=inputbox("請輸入一個數")next
dim min1 as double '記錄最小值dim min2 as integer '記錄下標min1=a(0):min2=0 '要賦初值for i = 1 to 19
if a(i)
min1=a(i):min2=i
end if
next
print "最小數是:" & min1 & " 其下標是:" & min2
2樓:悠悠周郎
dim a(19) as double
for i=0 to 19
a(i)=inputbox("輸入一個數")next
dim zuixiaoshu as doubledim zuixiaoshuxiabiao as integerfor i = 0 to 19
if a(i)
zuixiaoshuxiabiao=i
next
print "最小數是:" & zuixiaoshu & " 其下標是:" & zuixiaoshuxiabiao
3樓:匿名使用者
private sub command1_click()dim a(5) as single
for i = 0 to 5
a(i) = inputbox("請輸入一個數:")next i
dim min as single
dim minnum as integermin = a(0)
for i = 0 to 5
if a(i) < min then
min = a(i)
minnum = i
end if
next i
msgbox "最小的數是:" & min & " 下標是:" & minnum
end sub
4樓:匿名使用者
dim a(1 to 20)
dim min as double
dim xiabiao as integerprivate command1_click()for i=1 to 20
a(i)=val(inputbox("輸入一個數"))next i
min=a(1):xiabiao=1
for i = 2 to 20
if a(i)
min=a(i)
xiabiao=i
next i
print "最小數是:" ;min
print "其下標是:" ;xiabiaoend sub
vb程式設計宣告一個有10個元素的一維陣列a使用inputbox函式為所有元素賦值,將其最小元素的值及下標顯示出來
5樓:岔路程式緣
option explicit
private sub form_load()form1.autoredraw = truedim a(10) as single
dim i as byte
for i = 1 to 10
a(i) = val(inputbox("輸入bai第du" & i & "個數
zhi", "輸入", 88))
print a(i);
next
a(0) = 1
for i = 2 to 10
if a(a(0)) > a(i) then a(0) = inext
print "最小
dao的元
內素是第
容a("; a(0); ")"; "="; a(a(0))end sub
vb程式設計題,定義一下有20個元素的一維陣列,使用inputbox函式為陣列中的所有元素賦值,並顯示
6樓:匿名使用者
dim a(1 to 20) as integerprivate sub form_click()mx = a(1)
mn = a(1)
for i = 1 to 20
a(i) = inputbox("輸入一來個數自值", "輸入")if a(i) > mx then mx = a(i)if a(i) < mn then mn = a(i)next
print "最大值是
" & mx & ",最小值是" & mnend sub
7樓:匿名使用者
dim a(20)
dim i,j,k
for i=0 to 19
a(i) = inputbox("輸入第
baidu"& i + 1 &"個資料
:zhi")
if i=0 or j>a(i) thenj = a(i)
end if
if i=0 or k小
dao="& j &",最回
大答="& k )
宣告一個有20個元素的一維陣列a,使用inputbox函式為其所有元素賦值,然後將其所有元素的值及其下標顯示出 35
8樓:伶伶妖
private sub form_click()dim arry(20) as integerdim str1 as string
for i = 0 to 19
str1 = "請輸入第" + str(i) + "個值"
arry(i) = val(inputbox(str1, "輸入值"))
next i
for i = 0 to 19
print "下標為"; i; "你輸入的值為"; arry(i)print
next i
end sub
把這個貼到你的**上,我自己寫的,要給分哦。
9樓:_星_新
**如下:
private sub form_click()dim arry(20) as integerdim str1 as string
for index = 1 to 20
str1 = "請輸入第" + index + "個值"
arry(index - 1) = val(inputbox(str1, "輸入值"))
next index
for index = 0 to 19
print "下標為" + index + "你輸入的值為"+ arry(index)
next index
end sub
10樓:
private sub form_click()dim a(1 to 20), i as integer, j as integer
for i = 1 to 20
a(i) = inputbox("")
next i
for j = 1 to 20
print "a(" & j & ")=" & a(j)next j
end sub
宣告有一個20個元素的一 維陣列a,使用inputbox函式為其所有元素賦值,然後將其中最小元素用下標表示出來
11樓:
dim a(19) as single
dim i as integer
dim j as integer
for i=0 to 19
a(i)=val(inputbox("請輸入數字:"))next i
j=0for i=1 to 19
print "最小元素下標為:" & j
因為題目沒有說明是整數陣列,故以上假設為單精度陣列。
vb編寫程式:一個具有10個元素的一維陣列,下標從1到10,要求用inputbox從鍵盤上輸入其元
12樓:1號阿江
解:private sub command1_click()dim a(1 to 10) as doubledim min as double
for i=1 to 10
a(i)=val(inputbox("請輸入陣列元素值:"))next i
for i=1 to 10
if a(i)最小的數字
專為屬:" & min
end sub
13樓:逐鹿傳說
private sub command1_click()dim a(1 to 10)
dim b, c
b = val(inputbox(""))a(1) = b
for i = 2 to 10
c = val(inputbox(""))a(i) = c
if b > c then b = c
next
msgbox "最小:" & b
end sub
VB程式編寫 某陣列有元素,元素的值由鍵盤輸入,要求將前元素與後元素對換。高分懸賞
private sub command1 click dim str as string dim arr 1 to 20 as stringfor i 20 to 1 step 1arr i inputbox 請輸入第 21 i 個數 str str arr i next print 交換前 vbc...
定義NXN的二維陣列,輸入陣列元素的值,使陣列左下半三角元素中的值全部置成
假面 include define n 10 int main int a n n int i,j,n scanf d n for i 0 ifor j 0 j i j a i j 0 for i 0 ifor j 0 jprintf d a i j printf n return 0 二維陣列本質...
VB題 定義具有元素的一維陣列,並對其隨機賦值,然後求出其中元素值為奇數的元素的和
程式如下,用了二個列表框,乙個放隨機的20個數,另乙個放為奇數的,結果在視窗上列印出來。dim aa 20 as integerrandomize 隨機數初始化ss 0 for i 1 to 20 aa i rnd 1 1000 0.5 隨機產生乙個數,轉換為整數 list1.additem aa ...