Write a shell script to reverse the rows
and columns of a matrix.
Echo "Enter Number of rows"
read r
Echo "Enter Number of columns"
read c
i=0
echo "Enter elements"
until [ $i –eq `expr $r \* $c` ]
do
read a[$i]
i= `expr $i + 1`
done
i=0 ; k=0
echo "Transpose of a Matrix"
until [ $i –eq $c ]
do
j=0;
until [ $j –eq $r ]
do
n= `expr $j \* $c`
m= `expr $n + $i
b[$k] = ${a[$m]}
echo "${b[$k]} \t"
k= `expr $k + 1`
j= `expr $j + 1`
done
i = `expr $i + 1`
echo "\n"
done
No comments:
Post a Comment