vb点虐 求n的简单介绍

VB.NET2010 给定求组合数公式为Cmn=m!/n!(m-n)!,编一程序,输入m和n的值,求Cmn的值。要用Sub过程

Module Module1

逊克网站制作公司哪家好,找创新互联建站!从网页设计、网站建设、微信开发、APP开发、响应式网站建设等网站项目制作,到程序开发,运营维护。创新互联建站自2013年起到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联建站

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

用VB.NET编写一个程序 :编一求阶乘的函数f(n),主调程序求组合数的程序,分别调用f(n),用来计算组合数的值

Private Sub Command1_Click()

Dim A, B, C

A = 10

B = 3

C = f(A) / (f(B) * f(A - B))

Print C

End Sub

Private Function f(n)

Dim I As Integer

f = 1

For I = 1 To n

f = f * I

Next I

End Function

vb点虐 程序。求组合数,其中m,n用inputbox函数输入。要求用用户自定义过程计算阶乘,组

Public Class Form1

Private Function jc1(ByVal q)

Dim i%, p%

p = 1

For i = 1 To q Step 1

p = p * i

Next

Return p

End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim m!, n!, info1$, info2, C!, title$

title = "组合数计算小能手"

info1 = "请输入m的值"

info2 = "请输入n的值"

m = Val(InputBox(info1, title))

n = Val(InputBox(info2, title))

C = jc1(m) / jc1(n) / jc1(m - n)

Label1.Text = "结果是" " " C

End Sub


名称栏目:vb点虐 求n的简单介绍
标题链接:http://azwzsj.com/article/ddeppgg.html