大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Private Sub Command1_Click()
超过十余年行业经验,技术领先,服务至上的经营模式,全靠网络和口碑获得客户,为自己降低成本,也就是为客户降低成本。到目前业务范围包括了:成都网站设计、成都做网站,成都网站推广,成都网站优化,整体网络托管,微信小程序,微信开发,重庆APP开发,同时也可以让客户的网站和网络营销和我们一样获得订单和生意!
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
有一个字符串函数:Instr(n,S1,S2)
该函数的功能:从字符串S1的左起第N位开始,向右逐位进行搜索匹配字符串S2,如果找到匹配,就返回一个整数指明匹配的位置,否则就返回0。如果缺省n,就是默认从字符串S1的左起第1位开始,进行搜索匹配字符串S2。
例如1:Instr(1,"abcde","a"),返回1
例如2:Instr(3,"abcde","a"),返回0
例如3:Instr(1,"abcde","c"),返回3
例如4:Instr(1,"abcde","cde"),返回3
例如5:Instr(4,"ab12cd12e12","12"),返回7,这里从字符串"ab12cd12e12"左起第4位开始向右搜索匹配字符串"12",找到的是中间一个“12”,这个“12”是位于字符串"ab12cd12e12"左起的第7个字符。
而:Instr(1,"ab12cd12e12","12"),返回3
Instr("ab12cd12e12","12"),返回3
Dim d() As Integer
Dim n As Integer
Dim i As Integer
Dim j As Integer
Dim T As Integer
n = Val(InputBox("请输入n,确定数组的元素个数"))
ReDim d(n)
'用随机函数生成正整数数组
Randomize
For i = 1 To n
d(i) = Int(Rnd * 100 + 1)
Next i
'输出
For i = 1 To n
Print d(i),
Next i
'从小到大排序
For i = 1 To n - 1
For j = i + 1 To n
If d(i) d(j) Then
T = d(i)
d(i) = d(j)
d(j) = T
End If
Next j
Next i
'输出
For i = 1 To n
Print d(i),
Next i
Function P(ByVal N As Integer, ByVal x As Single) As Single
If N = 0 Then
Return 1
ElseIf N = 1 Then
Return x
Else
Return ((2 * N - 1) * x * P(N - 1, x) - (N - 1) * P(N - 2, x)) / N
End If
End Function
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