1樓:匿名使用者
dim str as string = "", temp as integer = 0, sum as integer = 0, x as integer
dim a(5, 5), b(5) as integerfor i = 1 to 5
for j = 1 to 5
a(i, j) = int(rnd() * 90 + 10)str = str & a(i, j) & " "
next
str = str & vbcrlf
next
str = str & vbcrlf
for i = 1 to 5
sum = sum + a(i, i)
next
for i = 1 to 5
for j = 1 to 5
for x = 1 to 5 - j
if a(i, x) < a(i, x + 1) thentemp = a(i, x + 1)
a(i, x + 1) = a(i, x)a(i, x) = temp
end if
next
next
next
for i = 1 to 5
b(i) = a(i, 1)
str = str & b(i) & " "
next
str = str & "主對角線數字和是" & sumtextbox6.text = str
執行結果:
73 58 62 36 37
79 11 78 83 73
14 47 87 81 43
96 88 15 95 42
57 79 14 63 52
73 83 87 96 79
主對角線數字和是318
2樓:大個小豆角
太簡單 給點財富 幫你編編。
vb 用隨機函式產生20個兩位數的整數,存於4行5列的二維陣列中,並求出其中的最大元素
3樓:匿名使用者
option explicit
option base 1
dim a%(80), i%, k%, t%, b%(80)private sub command1_click()me.cls
dim j as integer
randomize
for i = 1 to 80
a(i) = int(rnd * 90) + 10next i
k = 0
t = 1
for i = 1 to 79
b(i) = abs(a(i + 1) - a(i))if b(i) > k then
k = b(i)
t = i
end if
next i
print "全部"
for i = 1 to 80
print a(i);
if i mod 10 = 0 then printnext i
print "最大差值:" & k & ",是" & a(t + 1) & "和" & a(t) & "之差"
end sub請參考
vb程式,設有一個二維陣列a(4,5),其中每個元素均由兩位隨機整數構成,然後執行以下操作:
vb題目:輸出一個5×5的矩陣,其中元素是隨機生成的1-100的整數.
4樓:匿名使用者
private sub command1_click()randomize
form1.cls
dim c, e as integer
c = 0
e = 0
dim d as double
d = 1
dim a(4, 4) as stringfor i = 0 to 4
for j = 0 to 4
f = format(int(rnd * 100 + 1), "0,0")
if i = j or i + j = 4 then c = c + f: d = d * f
if f > e then e = f
a(i, j) = f
next
print a(i, 0) & " " & a(i, 1) & " " & a(i, 2) & " " & a(i, 3) & " " & a(i, 4)
next
print "對角線來的自
和為:" & c
print "對角線的
積為:" & d
print "最大的元素為:" & e
end sub
vb實驗:定義一個5x5的矩陣,用隨機函式產生各陣列元素的值(100以內的正整數)。找出矩陣中最大
5樓:匿名使用者
private sub command1_click()dim a(4, 4) as integer, tmp as integer
dim i as integer, j as integerrandomize timer
for i = 0 to 4
for j = 0 to 4
a(i, j) = int(rnd * 100)if tmp < a(i, j) then tmp = a(i, j)
print a(i, j);
next
next
print tmp
end sub
MATLAB如何生成3行4列均值為5的0 10隨機矩陣
1 rand 產生均值為0.5 幅度在0 1之間的偽隨機數 2 randn 產生均值為0 方差為1的高斯白噪聲 3 randperm n 產生1到n的均勻分佈隨機序列 4 normrnd a,b,c,d 產生均值為a 方差為b大小為cxd的隨機矩陣 求 matlab中輸出一個以0為均值,5為方差的隨...
用VB程式將1到25的自然數依次賦值給5 5的二維陣列並且輸出陣列的下三角
如下 private sub mand1 click dim a 1 to 6,1 to 6 as integerfor i 1 to 5 for j 1 to 5 tmp 99 if i tmp then tmp i end if if j tmp then tmp j end if if 6 i...
1355,的豎式怎麼列,1359x5用豎式計算怎麼寫
您好 135除5等於27。除法豎式列法如下圖所示。135 9x5用豎式計算怎麼寫?135 9x5 75 135 9x5 15x5 75 135 7的豎式怎麼列?197 135765 63219餘2 135 50豎式計算?你好朋友,根據你的描述 135 50 2.7 豎式計算如下圖 豎式計算 135 ...