- 20
- 0
- 约7.04千字
- 约 13页
- 2017-08-04 发布于河南
- 举报
组合数的序列号(The serial number of the combination)
The following program is Excel VBA code
The number (in ascending order, otherwise, must be sorted first) is converted to a serial number
This function does not test the validity of the data. The input data must be meaningful
when the amount of computation is large, the N is used as a private variable of the module or class, so that the initialization is not repeated when used.
Public Function NumberToSerial (ByVal N As Long, ByVal M As Long, by ref Numbers () As Long) As Long
When the amount of computation is large, CalTable () is used as a private variable of the module or class, so that it is not necessary to initiate the initialization when used.
The Dim CalTable () As Long
initialization ordinal calculation table: CalTable
If Not InitializeCalTable (N, M, CalTable) Then
NumberToSerial = 1
The Exit Function
End the If
Dim I As Long, j As Long, TempSerial As Long
TempSerial = 0
calculate the number of ordinal weights of the first number
For I = 1 To Numbers (1) -1
TempSerial = TempSerial + CalTable (I, 1)
Next
Dim ptrRowStart As Long points to the sequence number table to start the cumulative row
The Dim AccumulateRows As Long calculation table starts the cumulative number of rows
PtrRowStart = Numbers (1)
Calculate the weight of the serial number of two to M - 1 Numbers
For j = 2 To M - 1
AccumulateRows = Numbers (j) - (Numbers (j-1) + 1)
If AccumulateRows Then
For I = ptrRowStart To ptrRowStart + accumulaterowows -1
TempSerial = TempSerial + CalTable (I, j)
Next
PtrRowStart = ptrRowStart + AccumulateRows
End the If
Next
TempSerial = TempSerial + (Numbers (M) - Numbers (m-1))
NumberToSerial = TempSerial returns the result
End the Function
Serial number (in ascending order)
This function does not test the validity of the data. The input data must be meaningful
when the amount of computation is large, the N is used as a private variable of the module or class, so that the initialization is not repeated when used.
Publi
您可能关注的文档
- 肺炎链球菌肺炎(Pneumococcal pneumonia).doc
- 酚醛树脂(Phenolic resin).doc
- 风格讲解(Interpretation of the style).doc
- 风量与风压(Air volume and wind pressure).doc
- 风扇资料(Fan data).doc
- 风险管理习题(Risk management exercises).doc
- 风资源评价(Evaluation of wind resources).doc
- 高频鼓荡 深度刺激(High frequency drumbeat depth stimulation).doc
- 高速路驾驶,如何安全避让大货车(Highway driving, how to avoid large goods vehicles).doc
- 高速铁路的技术经济优势(The technological and economic advantages of high-speed railway).doc
- 2026年动物产品检疫追溯项目初步设计.docx
- 如祺出行-市场前景及投资研究报告-三角协同,构筑商业闭环,平台加速L4落地.pdf
- 北京财贸职业学院《康复医学》2025-2026学年期末试卷.doc
- 2026年建筑安装工程BIM+GIS协同应用一体化项目可行性研究报告.docx
- 2023年12月06日海口高新区国科实验动物有限公司海口国家高新区医药配套设施建设项目一期.pdf
- 北京财贸职业学院《康复治疗学》2025-2026学年期末试卷.doc
- 2026年小区安防设施标识清晰化建设初步设计.docx
- 《从教走向学》读书分享课件.pptx
- 北京财贸职业学院《康复医学导论》2025-2026学年期末试卷.doc
- 北京财贸职业学院《科学技术与社会》2025-2026学年期末试卷.doc
原创力文档

文档评论(0)