Str= "A|b|c|d"
Required to write a small program to draw:
A|b|c|d
B|c|d|a
C|d|a|b
D|a|b|c
As a result, the str length is undefined and the format is the top form.
The implementation code is as follows:
Copy Code code as follows:
Str= "A|b|c|d"
Call Sort (str, "|")
Function Sort (ssource, Sdelimiter)
Dim I, J, N, Sitems, stemp
Sitems = Split (ssource, Sdelimiter)
For I = 0 to UBound (sitems)
For J = 0 to UBound (sitems)
N = I + J
If N > UBound (sitems) Then
N = N-ubound (sitems)-1
End If
Stemp = stemp & Sitems (N) & Sdelimiter
Next
Stemp = Left (stemp, Len (stemp)-Len (Sdelimiter))
WScript.Echo Stemp
Stemp = ""
Next
End Function
Display in a window at the same time
Copy Code code as follows:
str = "A|b|c|d"
WSH. Echo Join (Sort (str, "|"), VBCRLF)
Function Sort (ByVal s, ByVal D)
Dim A, R (), I, J, H, index
A = Split (s, D)
H = UBound (a)
ReDim Preserve R (H)
index = Len (d) + 1
For i = 0 to H
R (i) = ""
For j = i to H + I
R (i) = R (i) & D & A (J Mod (H + 1))
Next
R (i) = Mid (R (i), index)
Next
Sort = R
End Function
Copy Code code as follows:
Str= "A|b|c|d"
WScript.Echo Sort (str, "|")
Function Sort (ssource, Sdelimiter)
Dim I, J, N, Sitems, stemp
Sitems = Split (ssource, Sdelimiter)
N = UBound (sitems)
For I = 0 to N
For J = 0 to N
Stemp = stemp & Sitems ((I + J) Mod (N + 1)) & Sdelimiter
Next
Stemp = Left (stemp, Len (stemp)-Len (Sdelimiter))
Sort = sort & stemp & VbCrLf
Stemp = ""
Next
Sort = Left (sort, Len (sort)-1)
End Function
Copy Code code as follows:
Str= "A|b|c|d"
MsgBox Sort (str, "|")
function sort (SS,SD)
Dim n,i
For I=0 To UBound (split (SS,SD))
Sort=sort+mid (Ss+sd+ss,n+1,len (ss)) +vbcrlf
N=instr (N+1,SS+SD+SS,SD)
Next
End Function