VB.NET2010 给定求组合数公式为Cmn=m!/n!(m-n)!,编一程序,输入m和n的值,求Cmn的值.要用Sub过程Imports System.ConsoleModule Module1Private Sub fac(ByVal x As ULong,ByVal y As ULong)Dim i&,a&a = 1For i = 1 To xa = a * iNext iy = aEnd
来源:学生作业帮助网 编辑:六六作业网 时间:2025/01/21 18:52:28
VB.NET2010 给定求组合数公式为Cmn=m!/n!(m-n)!,编一程序,输入m和n的值,求Cmn的值.要用Sub过程Imports System.ConsoleModule Module1Private Sub fac(ByVal x As ULong,ByVal y As ULong)Dim i&,a&a = 1For i = 1 To xa = a * iNext iy = aEnd
VB.NET2010 给定求组合数公式为Cmn=m!/n!(m-n)!,编一程序,输入m和n的值,求Cmn的值.要用Sub过程
Imports System.Console
Module Module1
Private Sub fac(ByVal x As ULong,ByVal y As ULong)
Dim i&,a&
a = 1
For i = 1 To x
a = a * i
Next i
y = a
End Sub
Sub Main()
Dim m&,n&,Cmn&,c1&,c2&,c3&
WriteLine("m=")
m = Val(ReadLine())
WriteLine("n=")
n = Val(ReadLine())
Call fac(m,c1) :Call fac(n,c2) :Call fac(m - n,c3)
Cmn = c1 / (c2 * c3)
Write("Cmn={0}",Cmn)
End Sub
End Module
老是说 Cmn = c1 / (c2 * c3)运算溢出,
VB.NET2010 给定求组合数公式为Cmn=m!/n!(m-n)!,编一程序,输入m和n的值,求Cmn的值.要用Sub过程Imports System.ConsoleModule Module1Private Sub fac(ByVal x As ULong,ByVal y As ULong)Dim i&,a&a = 1For i = 1 To xa = a * iNext iy = aEnd
Module Module1
Private Sub fac(ByVal x As ULong,ByRef y As ULong)
Dim i&,a&
a = 1
For i = 1 To x
a = a * i
Next i
y = a
End Sub
Sub Main()
Dim m&,n&,Cmn&,c1&,c2&,c3&
Console.WriteLine("m=")
m = Val(Console.ReadLine())
Console.WriteLine("n=")
n = Val(Console.ReadLine())
Call fac(m,c1) :Call fac(n,c2) :Call fac(m - n,c3)
Cmn = c1 / (c2 * c3)
Console.Write("Cmn={0}",Cmn)
End Sub
End Module