T=t*i S=s+t Endfor ?s
S=1/1!+1/2!+1/3!+。。。+1/n!,直到10^(-6)为止-条件-do while
1/n!小于
S=1/1!-1 /2!+1/3!-。。。1/n!,直到1/n! S=x^1/1!-x^2/2!+x^3/3!-。。。x^n/n!,直到x^n/n!小于10^(-6)为止,x由键盘输入
先判断后,符合条件就累加;再算下一项的阶乘。
S=1/1!+1/2!+1/3+…1/n! 直到1/n!小于10^(-6)为止
Input “x=” to x S=0 T=1 I=1
Do while x^i/t>=10^(-6) S=s+x^i/t*(-1)^(i+1) I=i+1 T=t*i
Enddo ?s return
S=1/1!-1/2!+1/3-…1/n!
S=x-x^2/2!+x^3/3-…x^n/n! Ex
=1+x+x^2/2!+x^3/3+…x^n/n! x^n/n!<10^(-8)为止,x键盘输入
直 到
E=1+x^1/1!+x^2/2!+x^3/3+…x^n/n! s=1+x^1/1!+x^2/2!+x^3/3+…x^n/n! Input “x=” to x S=1 T=1 I=1
Do while x^i/t>=10^(-8) S=s+x^i/t
x
条件
If 条件 then 语句序列1 [Else
语句序列2] Endif 两个 多分支
Do case
Case 条件1 语句1 。。。
[Otherwise] Endcase 循环-原理 1.
循环的初始化
Do while 循环条件-假 循环体-真
循环条件的修改 Enddo S=1+…n,n键盘输入 Input “n=” to n
S=0 I=2
Do while i<=n S=s+i I=i+2 Enddo ?s return
奇数 偶数 2.
For i=初值 to 循环体 Endfor(i=i+n)
S=1+2…+100
step n
终值
D=-d -变符号 Endfor ?s return
s=1+1/2+1/3+…1/n for- 1. 简练
2. 终止值必须确定
n键盘输入-
s=1/1+1/2+1/3+ 1/4 +1/5….+1/19 1/20 s=0
i=1-初始化
do while 1/i>=10^(-8)-条件 s=s+1/i-循环体 i=i+1-条件修改 enddo
?s return
循环的初始化
Do while 条件-假 循环体-条件为真 循环条件的修改
Enddo
1/n>=10^(-8)-循环-累加-条件 N-不能用for,只能用do while
直到1/n小于10^(-8)为止-停-不累加
S=1/1!+1/2!+1/3!+。。。确定-for
Input “N=” to n S=0 T=1
For i=1 to n
+1/n!,n由键盘输入-
For i=1 to n S=s*i Endfor ?s
Return
S=1+2+3+4+5 S=s+I i=1,2…5 S=1!+2!+3!+4!+5!
S=s+? t s=0 t=1
for i=1 to 5
t=t*i=1*1=1!*2=2!*3=3!*4=4!*5=5! s=s+1/t=0+1!+2!+3!+4!+5!= endfor ?s
return
1!=1*1 i=1,2,3,4,5 2!=1!*2 3!=2!*3 4!=3!*4 5!=4!*5
T=1
T=t*I i=1,2,3,4,5 I=1 T=1!=1
T=2!=1*2=1!*2=T*2
T=3!=1*2*3=2!*3=T*3 T=4!=1*2*3*4=3!*4=t*4 T=5! =1*2*3*4*5=4!*5=t*5
S=s+t t=1! 2!...5!
S=1!+ 2!+ 3!+ 4! 理解 先算阶乘,再累加
S=0 T=1
For i=1 to 4 i=1,2,3,4 5
T=t*i=1*1=1!*2=2!*3=3!*4=4! S=s+t=0+1!+2!+3!+4! Endfor(i=i+1) ?s return
S=0 T=1
For i=1 to 4 i=1,2,3,4 5 S=s+t=0+1!+1!+2!+3!
T=t*i=1*1=1!*2=2!*3=3!*4=4! Endfor(i=i+1) ?s return
S=1/1!-1/2!+1/3!-1/4!+…1/n! nS=1/2!+1/4!+1/6! S=0 T=1
For i=2 to 6 step 2 T=t*(i-1)*i
由键盘输入
S=s+1/t Endfor ?s return
s=1/3!-1/5!+1/7!-1/9!+…1/n! n 算阶乘,再累加 交换-影响结果
由键盘输入
Input “N=” to n S=0 T=1 D=1
For i=3 to n step 2 T=t*(i-1)*i- 项 S=s+1/t*d-累加
I=i+1 T=t*i Enddo ?s
Return
Cos(x)=1-x^2/2!+x^4/4!-x^6/6!+…x^n/n!, x^n/n!<10^(-8)为止 Input “x=” to x
S=1 T=2=2! I=2 D=-1
Do while x^i/t>=10^(-8)
S=s+x^i/t*d I=i+2
T=t*(I-1)*i
D=-d Enddo ?s
Return 小程序
大程序、复杂-小、简单
S=1+1/(1+2)+1/(1+2+3)+…1/(1+2+3…+10)
1. 前后两项间规律 2. 初始化 S=0 T=0
For i=1 to 10 i=1,2,3 T=t+I S=s+1/t Endfor
…10
?s
Return
T=t+I i=1,2,3..10 S=s+t
S=s+t
T=t+I i=1,2,3…10 T= T=0
T=0+1=1 T=1+2=t+2 T=1+2+3=t+3 T=1+2+3+4=t+4 …
T=(1+2+3…+10)=t+10
S=1/2!+1/4!+1/6!+…1/n! 1/n! <10^(-8)为止 正负间如何变化
S=1-x^2/2!+x^4/4!-x^6/6!+…x^n/n! X^n/n! <10^(-8)为止,x由键盘 Input “x=” to x S=1 T=2=2! I=2 D=-1
Do while x^i/t>=10^(-8)
S=s+x^i/t*d I=i+2
T=t*(i-1)*i D=-d enddo ?s return
Input “x=” to x S=0 T=1 I=1
Do while x^i/t>=10^(-6) S=s+x^i/t*(-1)^(i+1) I=i+1 T=t*i
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库2011.4基础班笔记-整理3在线全文阅读。
相关推荐: