1樓:珈藍惜夢
vb源程式如下:option base 1
private sub command1_click()dim a(5, 5) as integer, b(5, 5) as integer
for x = 1 to 5
for y = 1 to 5
a(x, y) = int(10 + rnd * 90) '隨機產生兩位數的整數
print a(x, y); '輸出
next
next
for x = 1 to 5
for y = 1 to 5
b(x, y) = a(y, x) '轉置print b(x, y); '輸出
next
next
end sub
程式輸出結果如下:
擴充套件資料:vb:編寫程式,實現如下規律的5*5矩陣存入陣列,並輸出該陣列private sub command1_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 < tmp then
tmp = 6 - i
end if
if 6 - j < tmp then
tmp = 6 - j
end if
a(i, j) = tmp
next j
next i
for i = 1 to 5
for j = 1 to 5
picture1.print tab(j * 5); a(i, j);
next j
picture1.print
next i
end sub
程式輸出結果如下:
2樓:會飛滴包子
option base 1
private sub command1_click()dim a(5, 5) as integer, b(5, 5) as integer
for x = 1 to 5
for y = 1 to 5
a(x, y) = int(10 + rnd * 90) '隨機產生兩位數的整數
print a(x, y); '輸出
next
next
for x = 1 to 5
for y = 1 to 5
b(x, y) = a(y, x) '轉置print b(x, y); '輸出
next
next
end sub
python中隨機生成10-99的整數,構成一個5×5的矩陣,顯示完整矩陣,並將矩陣轉置後顯示出來 5
3樓:好心bu分手
使用numpy 簡單的很
import numpy as np
import random
before = np.array([[random.randint(10, 99) for i in range(5)] for j in range(5)])
result = before.t
print(result)
4樓:匿名使用者
import numpy as np
matrix=random.randint(0,10,(5,5))print(matrix)
print(matrix.t)
C語言二維陣列程式設計題,C語言二維陣列程式設計題
第一道 include stdio.h define n 4 int main int f1 1,f2 1 for int i 0 i n i int result f1 f2 printf d n result return 0 第二道 include define n 10 int main e...
vb定義乙個二維陣列,求各維上下界
陣列名,不可預設。語法lbound arrayname dimension lbound 函式的語法包含下面部分 部分描述arrayname必需的。陣列變數的名稱,遵循標準的變數命名約定。dimension可選的 variant long 指定返回哪一維的下界。1 表示第一維,2 表示第二維,如此類...
設有二維陣列A 5,5 ,試用VB編寫程式
private sub command1 click for i 1 to 5 for j 1 to 5 if i 1 or j 1 or i 5 or j 5 then bsum bsum a i,j 所有靠邊元素之和 asum asum a i,j 所有元素之和if i j or i j 6 t...