使用Shell脚本完成菱形图形的绘制
PS:该菱形横向最大最好不要超过45
#! /bin/bash
read -p "请输入菱形大小:" g
for ((i=1;i<=$g;i++))
do
for ((j=$g;j>$i;j--))
do
echo -n " "
done
for ((p=1;p<=$i;p++))
do
echo -n "* "
done
echo ""
done
for ((k=$g-1;k>=1;k--))
do
for ((m=$g;m>$k;m--))
do
echo -n " "
done
for ((l=1;l<=$k;l++))
do
echo -n "* "
done
echo ""
done
效果图如下:
原文地址:https://blog.51cto.com/14484404/2441337
时间: 2024-10-13 12:11:26