我想假設a=9 k=7
那可能會有1~9的數列如同123456789
然後k=7 就從1數過來 數到第7個刪除
變成12345689 然後從下一個 也就是8開始數7個
然後把5刪除 變成1234689 依此類推
最後會剩下一個2
請問有什麼好方法 感謝
2006-10-09 10:50:17 · 1 個解答 · 發問者 ? 1 in 電腦與網際網路 ➔ 程式設計
'版本:VB6.0Private Sub Command1_Click() Dim A As Integer, K As Integer, I As Integer, S As String Do A = Int(Val(InputBox("請輸入數列值", , 9))) Loop Until A > 1 Do K = Int(Val(InputBox("請輸入間隔值", , 7))) Loop Until K > 0 For I = 1 To A S = S & I Next I = K Do Until Len(S) = 1 Mid(S, I Mod (Len(S) + 1), 1) = " " S = Replace(S, " ", "") I = (I + K - 1) Mod (Len(S)) If I = 0 Then I = Len(S) Print S LoopEnd Sub
2006-10-09 14:29:30 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋