急求此段c代码的vb代码!!!在线等!!!
char chars[anum];
int ptr=K
void comb(int N,int K)
{
if(K <=0)
{
printf( "%s\n ",chars); //输出并退出
return; //goback
}
chars[--ptr]=N+ '0 '; //从后往前生成一个数
comb(N-1,K-1); // 递归调用,生成前面K-1个数
ptr++;
if(N> K) comb(N-1,K); //如果第N位还没有达到最小植,继续向下取植
}
comb(6,3)的输出结果:
456
356
256
156
346
246
146
236
136
126
345
245
145
235
135
125
234
134
124
123
[解决办法]
调通了————多多指教
Option Explicit
Dim chars() As String
Dim p As Integer
Sub main()
Dim N As Integer
Dim K As Integer
N = 6: K = 3
ReDim chars(N * K - 1)
p = K
Call comb(N, K)
End Sub
Sub comb(ByVal N As Integer, ByVal K As Integer)
If (K <= 0) Then
Dim a As Integer
For a = 0 To UBound(chars)
Debug.Print chars(a);
Next a
Debug.Print
Exit Sub
End If
chars(p) = N & " " '//从后往前生成一个数
p = p - 1
Call comb(N - 1, K - 1) '//递归调用,生成前面K-1个数
p = p + 1
If (N > K) Then
Call comb(N - 1, K) '//如果第N位还没有达到最小植,继续向下取植
Else
End If
End Sub
急求此段c代码的vb代码!
急求此段c代码的vb代码!!!在线等!!!charchars[anum]intptrKvoidcomb(intN,intK){if(K 0){printf( %s\
