English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

請問一下位置轉換法的程式碼如何撰寫呢?例如,Pi(1,2,3,4)=(3,1,4,2),程式語言可以的話用JAVA、C、C++、VB撰寫,謝謝 ^^

2006-12-25 19:18:43 · 2 個解答 · 發問者 ? 5 in 電腦與網際網路 程式設計

2 個解答


'版本VB6.0
Private Sub Command1_Click()
Dim A() As String, I As Integer, S As String

S = "1234"
ReDim A(1 To Len(S))
For I = 1 To Len(S)
A(I) = Mid$(S, I, 1)
Next
Cal A(), "", String(Len(S), " ")
End Sub
Sub Cal(A() As String, S As String, K As String)
Dim I As Integer, X As String

If Len(S) = UBound(A) Then Print S: Exit Sub '輸出到表單

For I = 1 To UBound(A)
If Mid$(K, I, 1) = " " Then
X = K: Mid$(X, I, 1) = "*"
Cal A(), S & A(I), X
End If
Next
End Sub

2006-12-26 21:22:43 · answer #1 · answered by W.J.S. 7 · 0 0

你是要寫四個數的排列嗎?那應該和這篇類似吧..參考看看吧
印出傳入陣列中四個數字的所有排列方法
傳(a,b,c,d)進去的話..就在裡面用一個陣列存那四個數字..應該一樣吧 @﹏@
這種好像算作業題呢..而且都是類似句型重複發問..不知道會不會被移除呢 @﹏@
不過作業題會被刪的話..這裡很多丟問題叫人回答的..那些都會被刪了-.-

2006-12-26 14:09:55 · answer #2 · answered by ? 5 · 0 0

fedest.com, questions and answers