Mathcad 编程举例完整版.pdf
2007-04-29 评论:5 下载:7
下载
大小:225.43KB
将之前多个PDF合并了,方便大家使用!Mathcad 编程举例完整版
节选段落一:
29 实验 Mathcad (1)编程举例
1 1 100 3 7 .编写程序计算 - 之中可被 和 整除的整数之和
解 求解程序为:
div s 0←
s s k+← mod k 3,( ) 0= mod k 7,( ) 0=∨if
k 1 100..∈for
s
:=
div 2208=
d s 0← s1 0← s2 0←( )
s s k+← mod k 3,( ) 0=if
s1 s1 k+← mod k 7,( ) 0=if
s2 s2 k+← mod k 21,( ) 0=if
k 1 100..节选段落二:
∈for
"Chickens"
k
"Rabbits"
36 k−
:=
1 tong Mathcad : 36, 100, .鸡兔 笼问题的 程序 头 脚 求鸡、兔各若干
Mathcad (2)编程举例30 实验
Integ1 a b, n, f,( ) h
b a−( )
n
←
s f a( ) f b( )+( )
h
2
⋅←
s1 f a i h⋅+( ) h⋅←
s s s1+←
i 1 n 1−..节选段落三:
6435=C 6 2,( ) 15=
C n k,( )
n
k
C n 1− k 1−,( )⋅ k 0≠if
1 otherwise
:=
3 ( )计算组合数:
fac 6( ) 720=
fac n( ) 1 n 0=if
n fac n 1−( )⋅ otherwise
:=
2 ( )计算阶乘:
sum 100( ) 5050=
sum n( ) sum n 1−( ) n+ n 1>if
1 otherwise
:=
age 8( ) 44=
age n( ) 30 n 1=if
age n 1−( ) 2+ otherwise
:=
1( )计算和:
程序的递归调用实例:
Mathcad
29 实验 Mathcad (1)编程举例
1 1 100 3 7 .编写程序计算 - 之中可被 和 整除的整数之和
解 求解程序为:
div s 0←
s s k+← mod k 3,( ) 0= mod k 7,( ) 0=∨if
k 1 100..∈for
s
:=
div 2208=
d s 0← s1 0← s2 0←( )
s s k+← mod k 3,( ) 0=if
s1 s1 k+← mod k 7,( ) 0=if
s2 s2 k+← mod k 21,( ) 0=if
k 1 100..节选段落二:
∈for
"Chickens"
k
"Rabbits"
36 k−
:=
1 tong Mathcad : 36, 100, .鸡兔 笼问题的 程序 头 脚 求鸡、兔各若干
Mathcad (2)编程举例30 实验
Integ1 a b, n, f,( ) h
b a−( )
n
←
s f a( ) f b( )+( )
h
2
⋅←
s1 f a i h⋅+( ) h⋅←
s s s1+←
i 1 n 1−..节选段落三:
6435=C 6 2,( ) 15=
C n k,( )
n
k
C n 1− k 1−,( )⋅ k 0≠if
1 otherwise
:=
3 ( )计算组合数:
fac 6( ) 720=
fac n( ) 1 n 0=if
n fac n 1−( )⋅ otherwise
:=
2 ( )计算阶乘:
sum 100( ) 5050=
sum n( ) sum n 1−( ) n+ n 1>if
1 otherwise
:=
age 8( ) 44=
age n( ) 30 n 1=if
age n 1−( ) 2+ otherwise
:=
1( )计算和:
程序的递归调用实例:
Mathcad
查看更多评论 >