现在的位置: 首页 > 综合 > 正文

linux中for的用法

2014年02月09日 ⁄ 综合 ⁄ 共 379字 ⁄ 字号 评论关闭

1.用(())
#!/bin/bash
clear
for((i=1;i<100;i++))
        do
        if((i%3==0))
        then        echo $i
        continue
        fi
        done2.使用`seq 100`
#!/bin/bash
clear
for i in `seq 100` 
       do
        if((i%3==0))
 
       then 
       echo $i 
       continue
        fi
        done3.使用while
#!/bin/bash
clear
i=1
while(($i<100))
do
        if(($i%3==0)) 
       then 
       echo $i
        fi
        i=$(($i+1))
done

抱歉!评论已关闭.