分页: 1 / 1

请教一个shell怎么写

发表于 : 2008-11-28 16:48
hebiyu

***
*****
*******
得到这个结果,用for该怎么写。。。我实在是没思路,只晓得2*行数-1等于星星数,要不然就直接echo 了。。
先开个头。。
#! /bin/sh
for
:em06

Re: 请教一个shell怎么写

发表于 : 2008-11-28 17:46
xhy
python -c 'for j in [i for i in range(8) if i%2]: print "*"*j'

Re: 请教一个shell怎么写

发表于 : 2008-11-28 17:56
xhy

代码: 全选

python -c 'for i in range(1,8,2): print "*"*i'

Re: 请教一个shell怎么写

发表于 : 2008-11-30 20:42
flashchen
# !/bin/sh

for count in 1 3 5 7
do
while test $count -ge 1
do
echo -n $"*"
count=$(expr $count - 1)
done
echo
done

Re: 请教一个shell怎么写

发表于 : 2008-11-30 21:03
xiooli
echo -e "*\n***\n*****\n******* " 这个最简洁呢:em09

Re: 请教一个shell怎么写

发表于 : 2008-12-01 13:52
flashchen
晕。楼上的没按照楼主的要求。楼主开了头的
哈哈,不过功能实现了
确实很简单 :em11