#!/bin/bash
declare -a array
printf 'Matrix size:' ;
read n;
printf '\n';
for ((i=1;i<=n;i++))
do
for((j=1;j<=n;j++))
do
printf 'x[%d][%d]=' ${array[i][j]};
read array[i][j];
done
done
echo "Initial matrix:"
for((i=1;i<=$n;i++))
do
for ((j=1;j<=n;j++))
do
printf '%d' ${array[i][j]};
printf '\n';
done
done
A 无法显示 bash 数组并且不明白我的错误在哪里。例如我有:n=3....我在数组 (1-9) 中输入数字当我显示时:初始矩阵:3 3 3 6 6 6 9 9 9 Thx