#16223: bash shell


a0983095871@gmail.com (Lesson One)

學校 : 不指定學校
編號 : 73922
來源 : [1.168.170.69]
最後登入時間 :
2023-11-26 17:44:09
a015. 矩陣的翻轉 | From: [111.246.64.98] | 發表日期 : 2018-12-08 16:14

#!/bin/bash
while read row colu; do
  declare -A arr
  for i in `seq 1 $row`; do
   	 read rows
   	 arr+=(["$i"]=$rows)
    done
    for i in `seq 1 $colu`; do
   	 for j in `seq 1 $row`; do
   		 echo -n `echo ${arr[$j]} | cut -d ' ' -f $i`
   		 if [ $j -ne $row ]; then
   			 echo -n " "
   		 fi
   	 done
   	 printf "\n"
    done
done
 
ZeroJudge Forum