shell脚本(for,if,while)

#!/bin/bash
s=0
for ((i=1;i<=100;i=i+1))
do
    ((s=$s+$i))
done
echo $s

if [ $s -eq 5050 ]
then
    echo "right"
else
    echo "wrong"
fi

i=0
s=0
while [ $i -le 100 ]
do
    ((s=$s+$i))
    ((i=$i+1))
done
echo $s

以后笔记本的环境就设为Linux了,是到了该熟悉这个环境的时候了。
实验室依旧使用windows.
posted @ 2012-07-08 20:26  Dsp Tian  阅读(599)  评论(0编辑  收藏  举报