# One 、99 Multiplication table

``````#!/bin/bash

for ((a=1;a<=9;a++))
do
for ((b=1;b<=\$a;b++))
do
c=\$[\$a*\$b]
echo -n -e  "\$a*\$b=\$c\t"

done
echo ""

done
``````

# Two 、 rectangular

``````#!/bin/bash

for ((a=1;a<=5;a++))
do
for ((b=1;b<=10;b++))
do
echo -n "*"
done

echo ""
done
``````

# 3、 ... and 、 A straight line

``````#!/bin/bash
for ((a=1;a<=15;a++))
do
echo -n "*"
done
echo ""
``````

# Four 、 Right triangle

``````#!/bin/bash
for ((a=1;a<=9;a++))
do
for ((b=1;b<=\$a;b++))
do
echo -n "*"

done
echo ""
done
``````

# 5、 ... and 、 Anti right triangle

## 1、 Space, rectangle and triangle

``````#!/bin/bash
for ((a=1;a<=9;a++))
do
for ((b=1;b<=10;b++))
do
echo -n " "
done
for ((c=1;c<=\$a;c++))
do
echo -n "*"

done
echo ""
done
``````

## 2、 Space inverted triangle plus triangle

``````#!/bin/bash
for ((a=1;a<=9;a++))
do
for ((b=9;b>=\$a;b--))
do
echo -n " "
done
for ((c=1;c<=\$a;c++))
do
echo -n "*"

done
echo ""
done
``````

# 6、 ... and 、 An inverted right triangle

``````#!/bin/bash
for ((a=1;a<=9;a++))
do
for ((b=9;b>=\$a;b--))
do
echo -n "*"
done
echo ""
done
``````

# 7、 ... and 、 Isosceles right triangle

## 1、 Algorithm calculation \$a*2-1

``````#!/bin/bash
for ((a=1;a<=9;a++))
do
for ((b=9;b>=\$a;b--))
do
echo -n " "
done

for ((c=1;c<=\$[\$a*2-1];c++))
do
echo -n "*"
done
echo ""
done
``````

## 2、 Triangle plus little triangle

``````#!/bin/bash
for ((a=1;a<=9;a++))
do
for ((b=9;b>=\$a;b--))
do
echo -n " "
done

for ((c=1;c<=\$a;c++))
do
echo -n "*"
done

for ((d=2;d<=\$a;d++))
do
echo -n "*"
done
echo ""
done
``````

# 8、 ... and 、 Isosceles trapezoid

``````#!/bin/bash
for ((a=1;a<=9;a++))
do
for ((b=9;b>=\$a;b--))
do
echo -n " "
done
for ((c=1;c<=9;c++))
do
echo -n "*"
done
for ((d=1;d<=\$[\$a*2-1];d++))
do
echo -n "*"
done
echo ""
done
``````

# Nine 、 The diamond

``````#!/bin/bash
for ((a=1;a<=9;a++))
do
for ((b=9;b>=\$a;b--))
do
echo -n " "
done
for ((c=1;c<=\$[\$a*2-1];c++))
do
echo -n "*"
done
echo ""
done

for ((d=1;d<=10;d++))
do
for ((e=2;e<=\$d;e++))
do
echo -n " "
done
for ((f=10;f>=\$d;f--))
do
echo -n "*"
done
for ((g=9;g>=\$d;g--))
do
echo -n "*"
done

echo ""
done
``````

# Ten 、 Adjustable size diamond

``````#!/bin/bash
read -p " Input size " i

for ((a=1;a<=\$i;a++))
do
for ((b=\$i;b>=\$a;b--))
do
echo -n " "
done
for ((c=1;c<=\$[\$a*2-1];c++))
do
echo -n "*"
done
echo ""
done

for ((d=1;d<=\$i+1;d++))
do
for ((e=1;e<=\$d-1;e++))
do
echo -n " "
done
for ((f=2*\$i+1;f>=\$[\$d*2-1];f--))
do
echo -n "*"
done
echo ""
done
``````

https://cdmana.com/2020/12/20201225102952100y.html

Scroll to Top