问题标题:
linux-shell编程1.根据不同的分数段,输出不同的级别(如60及格,70-80中,80-90良,90-100优,60分以下不及格)2.输出1...10的平方3.输出1...100中能被5整除的数。
问题描述:
linux-shell编程
1.根据不同的分数段,输出不同的级别(如60及格,70-80中,80-90良,90-100优,60分以下不及格)
2.输出1...10的平方
3.输出1...100中能被5整除的数。
刘志芳回答:
(1)
#!/bin/bash
#如60及格,70-80中,80-90良,90-100优,60分以下不及格
whiletrue
do
echo-n"inputscores:"
readscore
if[$score="q"]
thenexit
fi
if[$score-lt60]
then
echo"不及格"
elif[$score-eq60]
then
echo"及格"
elif[$score-ge70-a$score-lt80]
thenecho"中"
elif[$score-ge80-a$score-lt90]
thenecho"良"
elif[$score-ge90-a$score-lt100]
thenecho"优"
fi
done
(2)
#!/bin/bash
#输出1...10的平方
fornin12345678910
do
echo-n$(($n*$n))
echo-n""
done
echo""
(3)
#!/bin/bash
#输出1...100中能被5整除的数
foriin{1..100}
do
if[$(($i%5))-eq0]
thenecho$i
fi
done
查看更多
八字精批
八字合婚
八字起名
八字财运
2024运势
测终身运
姓名详批
结婚吉日