菱形的shell脚本
这次我给大家带了菱形的shell脚本,没关系,错过了我下次还有其他的脚本给你们~
#! /bin/bash
read -p “请输入菱形大小:” g
for ((i=1;i<=
g
;
i
+
+
)
)
d
o
f
o
r
(
(
j
=
g;i++)) do for ((j=
g;i++))dofor((j=g;j>
i
;
j
−
−
)
)
d
o
e
c
h
o
−
n
"
"
d
o
n
e
f
o
r
(
(
p
=
1
;
p
<
=
i;j--)) do echo -n " " done for ((p=1;p<=
i;j−−))doecho−n""donefor((p=1;p<=i;p++))
do
echo -n "* "
done
echo “”
done
for ((k=
g
−
1
;
k
>
=
1
;
k
−
−
)
)
d
o
f
o
r
(
(
m
=
g-1;k>=1;k--)) do for ((m=
g−1;k>=1;k−−))dofor((m=g;m>
k
;
m
−
−
)
)
d
o
e
c
h
o
−
n
"
"
d
o
n
e
f
o
r
(
(
l
=
1
;
l
<
=
k;m--)) do echo -n " " done for ((l=1;l<=
k;m−−))doecho−n""donefor((l=1;l<=k;l++))
do
echo -n "* "
done
echo “”
done
这就是传说中的菱形的shell脚本,大同小异的小脚本~