#!/bin/bash
# How to make a random matrix in bash in that program,
# I don't understand how to make a random matrix in shell script.
# read the matrix order
read -p "Give rows and columns: " n
# accept elements
echo "Matrix element:"
let i=0
while [ $i -lt $n ]
do
let j=0
while [ $j -lt $n ]
do
read x[$(($n*$i+$j))]
j=$(($j+1))
done
i=$(($i+1))
done
1条答案
按热度按时间yyhrrdl81#
如果您只想**显示 * a排列在n X n矩阵中的数字,那么下面将为您提供一些关于如何获取随机数并将其传递到脚本的“格式化”部分的想法。