| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 354 人关注过本帖
标题:代码输出
只看楼主 加入收藏
BBS345
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-5-17
收藏
 问题点数:0 回复次数:0 
代码输出

小弟实在对VB一壳不通 现有美女给我一端程序 如下:请问它的输出 下半辈子全靠你们了
Option Explicit
Option Base 1
Const lCol As Long = 1 ' Writes in Column A

Sub AlmostLangford()
Dim iDigits(), iNDigits As Integer, lRow As Long

For iNDigits = 2 To 18 Step 2
ReDim iDigits(iNDigits)
Call AlmostLangfordN(iDigits, lRow)
Next

End Sub

Sub AlmostLangfordN(ByRef iDigits(), ByRef lRow As Long)
Dim iPosFree As Integer, iDigitsTmp(), iDigit As Integer
Dim iNDigits As Integer, i As Integer

iNDigits = UBound(iDigits)
Do While True
'Checks if last free position was filled
If iPosFree <> 0 Then If IsEmpty(iDigits(iPosFree)) Then Exit Sub
'Determines next free position
For iPosFree = iPosFree + 1 To iNDigits
If IsEmpty(iDigits(iPosFree)) Then Exit For
Next
If iPosFree = iNDigits + 1 Then Exit Sub

' Tries all digits
For iDigit = 0 To 9
If iPosFree + iDigit + 1 > iNDigits Then Exit For
' Checks if digit already used
For i = 1 To iNDigits
If iDigits(i) = iDigit And Not IsEmpty(iDigits(i)) Then Exit For
Next
' Cannot start with zero
If i > iNDigits And Not (iPosFree = 1 And iDigit = 0) Then
If IsEmpty(iDigits(iPosFree + iDigit + 1)) Then
' Initialises idigitstmp
ReDim iDigitsTmp(iNDigits)
For i = 1 To iNDigits
iDigitsTmp(i) = iDigits(i)
Next
iDigitsTmp(iPosFree) = iDigit
iDigitsTmp(iPosFree + iDigit + 1) = iDigit

' Checks if array is full (Almost-Langford number)
For i = 1 To iNDigits
If IsEmpty(iDigitsTmp(i)) Then Exit For
Next
If i > iNDigits Then
lRow = lRow + 1
Cells(lRow, lCol) = "'" & Join(iDigitsTmp, "")
Else
Call AlmostLangfordN(iDigitsTmp, lRow) 'iDigit + 1
End If
End If
End If
Next iDigit
Loop

End Sub

搜索更多相关主题的帖子: 代码 输出 
2007-05-17 17:34
快速回复:代码输出
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015497 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved