组合数的序列号(The serial number of the combination).docVIP

  • 20
  • 0
  • 约7.04千字
  • 约 13页
  • 2017-08-04 发布于河南
  • 举报

组合数的序列号(The serial number of the combination).doc

组合数的序列号(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

文档评论(0)

1亿VIP精品文档

相关文档