534216789.
程序代码如下:
Private Sub Degr(p() As Integer,ByVal n As Integer)
Dim i As Integer,j As Integer
Do While n > 0
OutL p
If p(1) = n Then '如果第一位是n
i = 0
Do '从左端开始找出最长的连续递降序列
i = i + 1
If i = n Then Exit Sub
Loop Until p(i) p(i + 1) + 1
j = i
Do '找出递降序列末尾数字的下一个数字
i = i + 1
Loop Until p(i) = p(j) - 1
Swap p(i),p(i - 1) '将它与序列末尾数字交换
For i = 1 To n - j '将递减序列倒转后放置在排列右端
p(i) = p(i + j)
Next
For i = 1 To j
p(n - i + 1) = n - i + 1
Next
Else '如果最高位不是n
i = 0 '从左端开始
Do '找出n所在位置
i = i + 1
Loop Until p(i) = n
Swap p(i),p(i - 1)'将n与其左边数字交换
End If
Loop
End Su