- shell脚本打印平行四边形
#!/bin/bash for ((i=1;i<=9;i++)) do for ((j=9;j>=i;j--)) do echo -n " " done for ((j=2;j<=i;j++)) do echo -n "*" done for ((j=1;j<=i;j++)) do echo -n "*" done for ((j=9;j>=i;j--)) do echo -n "*" done for ((j=9;j>=i;j--)) do echo -n "*" done echo done
- shell脚本打印菱形
#! /bin/bash for ((i=1;i<=9;i++)) do for ((j=9;j>=i;j--)) do echo -n " " done for ((j=2;j<=i;j++)) do echo -n "*" done for ((j=1;j<=i;j++)) do echo -n "*" done echo done for ((i=1;i<=9;i++)) do for ((j=1;j<=i;j++)) do echo -n " " done for ((j=8;j>=i;j--)) do echo -n "*" done for ((j=9;j>=i;j--)) do echo -n "*" done echo done
原文地址:https://www.cnblogs.com/tanxiaojuncom/p/11432152.html
时间: 2024-10-12 05:57:12