八年級信息技術教案第五章 循環(huán)結構程序設計
next a
end
(2)let m=1
input a,b,c
for i=a to b step c
let m=m*i
next i
print m
end
①輸入l,5,1 ②輸入50,-l,-1
結果為: 結果為:
(3)let t=1
let a=0
for k=l t0 5
let a=a+t*k
t=-t
next k
print a
end
結果為:
(4)let m=0
for x=1 to 10
if int(x/2)=x/2 then
let m=m+x
end if
next x
print m
end
結果為:
(5)let s=o
let x=2
do while s<30
let s=s+
loop
print s
end
(6)let a=l
let b=l
d0 while b<20
print a,b
let a=a+b
let b=a+b
loop
end
2.根據(jù)題意,把程序填寫完整
(1)求1/2+2/3+3/4+…+99/100的值。
let s=0
for i=l to
let s=
next i
print s
end
(2)把輸入的6個數(shù)中絕對值大于5的數(shù)打印出來,并統(tǒng)計這樣的數(shù)的個數(shù)。
let t=0
for j=1 t0 6
input x
if then
print x,
end if
next j
print “t=”;t
end
教學后記:
第二節(jié) 小小統(tǒng)計員-----while—wend語句
一、學習目標
了解while—wend語句的特點。
二、教學重點
while—wend語句的使用方法。
三、教學難點
while—wend語句的應用。
四、教學方法
1.演示法。
2.實踐法。
五、教學手段與教學媒體
多媒體網(wǎng)絡教室。
六、課時安排
1課時。
七、教學過程
教學內(nèi)容、步驟與方法
二、while循環(huán)結構 while <條件>
<循環(huán)體>wend
注: <條件>是終止循環(huán)的邏輯表達式,<條件>應隨循環(huán)的執(zhí)行而變化,最終退出循環(huán)!
如: s=0
i=1
while i<=100
s=s+i
wend
構成“死循環(huán)”——無終止的循環(huán)。這時可用ctrl+break終止其程序運行!
例1(p152例7.5): 如果我國工農(nóng)業(yè)生產(chǎn)每年以12%速度增長,問多少年后產(chǎn)值翻一番:基值設為100。
(逐年計算產(chǎn)值,看是否達到200)