1樓:匿名使用者
程式如下,用了二個列表框,乙個放隨機的20個數,另乙個放為奇數的,結果在視窗上列印出來。
dim aa(20) as integerrandomize '隨機數初始化ss = 0
for i = 1 to 20
aa(i) = rnd(1) * 1000 + 0.5 '隨機產生乙個數,轉換為整數
list1.additem aa(i)
if (aa(i) mod 2) = 1 then '判斷數是否為奇數
ss = ss + aa(i)
list2.additem aa(i)
end if
next i
print ss '元素值為奇數的元素的和
2樓:吾桐語
20個元素,每5個列印一行
private sub command1_click()dim a(20) as integer, s as integerfor i = 1 to 20
a(i) = int(rnd * 1000) + 1print a(i);
if i mod 5 = 0 then printnext i
for i = 1 to 20
if a(i) mod 2 <> 0 thens = s + a(i)
end if
next i
print " 奇數和為:" & s
end sub
3樓:匿名使用者
private sub command1_click()dim a(1 to 20) as single, sum as single, str as string
sum = 0: str = ""
for i = 1 to 20
randomize
a(i) = int(100 * rnd + 1)str = str & format(cstr(a(i)), "@@@")
if a(i) mod 2 <> 0 thensum = sum + a(i)
str = str & " 奇數"
end if
str = str & vbcrlf
next i
str = str & vbcrlf
msgbox str & "所有奇數的和=" & sumend sub
一、建立乙個10個元素的int陣列, 1) 隨機賦值 100以內的整數 2) 按降序排序 3) 輸出排序後的陣列元素 30
4樓:兄弟連教育北京總校
#include
#include
#include
int main()
for(i = 0; i < 10; i ++)printf("%d ", a[i]);}
5樓:_葉子妞妞
這個 不就是昨天那個嘛...
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
定義二維陣列4 4,二維陣列中的陣列元素都用鍵盤賦值。求出該二維陣列中主對角線的和C語言
include stdio.h include conio.h include stdlib.h main for i 0 i 4 i printf 此矩陣主對角線的和為 d n num include define m 4 int main int i,j,a m m sum 0 for i 0 ...
用vb編寫求元素的一維陣列A,使用INPUTBOX函式賦值,輸出最小元素的值及其下標
尤在尤存 一樓有問題.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...
VB語言定義大小為元素的整型陣列
司馬刀劍 private sub command1 click dim a n as integera array 999,15,28,37,45,58,61,75,85,90,92 print 原有的陣列元素是 for i 1 to ubound a print a i next i print ...