用VFP解答~编写一个程序,求S=A!+B!+C!,其中A,B,C从键盘输入,

来源:百度知道 编辑:UC知道 时间:2024/05/09 10:39:14
编写一个程序,求S=A!+B!+C!,其中A,B,C从键盘输入,阶乘分别利用自定义函数和过程两种方法实现。
记得是两种方法哦~! 步骤要详细一些,谢谢!
注明函数 和过程两种方法

我只给你写一种,第二种你自己改吧
clear
input "请输入a:" to a
input "请输入b:" to b
input "请输入c:" to c

s=fa(a)+fa(b)+fa(c)
?"a!+b!+c!=", s
return

proc fa
para x
p=1
for i=1 to x
p=p*i
endfor
return p
endproc

input "A=" to a
input "B=" to a
input "C=" to a
s=jc(a)+jc(b)+jc(c)
print s
*这句好象有问题,我忘记最简单的输出语句是什么了,几种语言容易搞在一起。

proc jc
para n
s1=1
for i=2 to n
s=s*i
endfor
retu s1