设计一个过程(函数或子程序):计算n!=1×2×3×…×n。用主调函数过程调用这个过程并完成下列任务:

高分求住

第1个回答  2008-06-14
你要求用什么语言?
下面给个VB
Sub xx()
Dim x As Long
'(9!+3!)*5!/(7!-4!)
x = (jc(9) + jc(3)) * jc(5) / (jc(7) - jc(4))
Print x
End Sub

Public Function jc(n As Integer) As Long
Dim i As Integer, s As Long
s = 1
For i = 2 To n
s = s * i
Next
jc = s
End Function
--------------------------------------------
下面是C的
int compute( int x )
{
if( x == 0)
return 1;
else
return x*compute( x - 1 );
}
相似回答