曲径通幽论坛

标题: 一个输出数字序列脚本 [打印本页]

作者: beyes    时间: 2009-7-8 00:04
标题: 一个输出数字序列脚本
百度答题,问题为,输出以下内容:
0
10
210
3210
43210
543210
6543210
76543210
876543210
实现脚本如下
#!/bin/sh
temp=0
temp1=$(($temp+1))
count=8
echo  "$temp"
while [ $count -gt 0 ]
do
temp=`echo -n "$temp1";echo -n "$temp"`      #将上一次的输出结果和下一次输出结果的第一个数字连结起来,如 5 连结 43210
echo "$temp"
temp1=$(($temp1+1))
count=$(($count-1))
done






欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) Powered by Discuz! X3.2