BUT2/SCR/SCR1.1/TP08/mult_mat.sh

24 lines
341 B
Bash
Raw Normal View History

2023-10-23 13:23:36 +02:00
## créer une table de multiplication
#!/bin/bash
if [[ $# -lt 2 ]]
then
echo "Usage: $0 <numeric_argument> <numeric_argument>"
exit
fi
arg1=$1
arg2=$2
if [[ $1 -gt $2 ]]
then
arg1=$2
arg2=$1
fi
for((x=$arg1 ; x<=$arg2 ; x++))
do
for((y=$arg1 ; y<=$arg2 ; y++))
do
printf "%5d " "$((x*y))"
done
echo
done
exit