編寫程序,根據輸入的行列數值,生成相應的矩陣(其中元素爲隨機數)。

python3實現

import random
x = y = 0
x_input = int(input("請輸入行的值:"))
y_input = int(input("請輸入列的值:"))
while x < x_input:
    y = 0
    while y < y_input:
        print(random.randint(1, 100), end="\t")
        y += 1
    print()
    x += 1

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章