밑으로
#! /bin/bash
echo "구구단"
for((i=2;i<=5;i++))
do
for((j=1;j<=9;j++))
do
num=`expr $i \* $j`
echo " $i X $j = $num "
done
echo ""
done
2 X 1 = 2
2 X 2 = 4
2 X 3 = 6
2 X 4 = 8
2 X 5 = 10
2 X 6 = 12
2 X 7 = 14
2 X 8 = 16
2 X 9 = 18
3 X 1 = 3
3 X 2 = 6
3 X 3 = 9
3 X 4 = 12
3 X 5 = 15
3 X 6 = 18
3 X 7 = 21
3 X 8 = 24
3 X 9 = 27
4 X 1 = 4
4 X 2 = 8
4 X 3 = 12
4 X 4 = 16
4 X 5 = 20
4 X 6 = 24
4 X 7 = 28
4 X 8 = 32
4 X 9 = 36
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
5 X 8 = 40
5 X 9 = 45
옆으로
#! /bin/bash
echo "구구단"
for((i=1;i<=9;i++))
do
for((j=2;j<=5;j++))
do
num=`expr $j \* $i`
echo -n " $j X $i = $num "
done
echo ""
done
2 X 1 = 2 3 X 1 = 3 4 X 1 = 4 5 X 1 = 5
2 X 2 = 4 3 X 2 = 6 4 X 2 = 8 5 X 2 = 10
2 X 3 = 6 3 X 3 = 9 4 X 3 = 12 5 X 3 = 15
2 X 4 = 8 3 X 4 = 12 4 X 4 = 16 5 X 4 = 20
2 X 5 = 10 3 X 5 = 15 4 X 5 = 20 5 X 5 = 25
2 X 6 = 12 3 X 6 = 18 4 X 6 = 24 5 X 6 = 30
2 X 7 = 14 3 X 7 = 21 4 X 7 = 28 5 X 7 = 35
2 X 8 = 16 3 X 8 = 24 4 X 8 = 32 5 X 8 = 40
2 X 9 = 18 3 X 9 = 27 4 X 9 = 36 5 X 9 = 45