首先我来解释一下什么是“亚瑟王环”,“亚瑟王环”是一道数学题,简单的举个例子相信大家就都理解了。
#!/bin/bash
for i in {1..100}
do
shuzu[$i]=$i //给数组赋值
done
shushu=0
while true;do
jishuqi=0 //计数器
for i in {1..100};do
if [ ${shuzu[$i]} -gt 0 ];then
shushu=$[$shushu+1]
jishuqi=$[$jishuqi+1]
huan=${shuzu[$i]}
fi
if [[ $shushu -eq 12 ]];then
echo -n ${shuzu[$i]}'->'
shushu=0
shuzu[$i]=0
fi
done
if [ $jishuqi -eq 1 ];then
break
fi
done
echo "最后得数:"$huan