排列组合问题。
排列组合问题。
<%
排列组合问题。
排列组合问题。
'算法程序题:
排列组合问题。
    '该公司笔试题就1个,要求在10分钟内作完。
排列组合问题。
    '题目如下:用1、2、2、3、4、5这六个数字,用java写一个main函数,打印出所有不同的排列,
排列组合问题。
    '如:512234、412345等,要求:"4"不能在第三位,"3"与"5"不能相连
排列组合问题。
    
排列组合问题。
排列组合问题。    
Dim i, i1, i2, i3, i4, i5, i6 '循环变量
排列组合问题。
    Dim t1, t2, t3, t4, t5 '临时变量
排列组合问题。
    Dim pre, cur '上一位,当前位
排列组合问题。
    Dim num '生成的数字串
排列组合问题。
    Dim appear(5'判断某个数字是否出现过的数组 例:appear(1)的值为0表示1没有出现过,值为1表示1出现过 
排列组合问题。

排列组合问题。    pre 
= 0 '初始化为一个不相关的数字
排列组合问题。
    For i = 1 To 5
排列组合问题。        appear(i) 
= 0
排列组合问题。    
Next
排列组合问题。
排列组合问题。    
排列组合问题。    
For i1 = 1 To 5
排列组合问题。        cur 
= i1
排列组合问题。        
If Not(pre = 3 And cur = 5And Not(pre = 5 And cur = 3Then
排列组合问题。            pre 
= cur
排列组合问题。            
排列组合问题。            
For i2 = 1 To 5
排列组合问题。                t1 
= pre '保护pre的值,防止在下面的操作中值被改变
排列组合问题。
                cur = i2
排列组合问题。                
If Not(pre = 3 And cur = 5And Not(pre = 5 And cur = 3Then
排列组合问题。                    pre 
= cur
排列组合问题。                    
排列组合问题。                    
For i3 = 1 To 5
排列组合问题。                        t2 
= pre
排列组合问题。                        cur 
= i3
排列组合问题。                        
If Not(pre = 3 And cur = 5And Not(pre = 5 And cur = 3Then
排列组合问题。                            
If cur <> 4 Then
排列组合问题。                                pre 
= cur
排列组合问题。                                
排列组合问题。                                
For i4 = 1 To 5
排列组合问题。                                    t3 
= pre
排列组合问题。                                    cur 
= i4
排列组合问题。                                    
If Not(pre = 3 And cur = 5And Not(pre = 5 And cur = 3Then
排列组合问题。                                        pre 
= cur
排列组合问题。                                        
排列组合问题。                                        
For i5 = 1 To 5
排列组合问题。                                            t4 
= pre
排列组合问题。                                            cur 
= i5
排列组合问题。                                            
If Not(pre = 3 And cur = 5And Not(pre = 5 And cur = 3Then
排列组合问题。                                                pre 
= cur
排列组合问题。                                                
排列组合问题。                                                
For i6 = 1 To 5
排列组合问题。                                                    t5 
= pre
排列组合问题。                                                    cur 
= i6
排列组合问题。                                                    
If Not(pre = 3 And cur = 5And Not(pre = 5 And cur = 3Then
排列组合问题。                                                        
排列组合问题。                                                        appear(i1) 
= 1 '给出现过的数字打上标识
排列组合问题。
                                                        appear(i2) = 1
排列组合问题。                                                        appear(i3) 
= 1
排列组合问题。                                                        appear(i4) 
= 1
排列组合问题。                                                        appear(i5) 
= 1
排列组合问题。                                                        appear(i6) 
= 1
排列组合问题。
排列组合问题。                                                        
If appear(1= 1 And appear(2= 1 And appear(3= 1 And appear(4= 1 And appear(5= 1 Then '组合成的结果中所有数字必须都出现过
排列组合问题。
                                                            num = i1 & i2 & i3 & i4 & i5 & i6
排列组合问题。                                                            response.write num 
& "<br />"
排列组合问题。                                                            num 
= ""
排列组合问题。                                                        
End If
排列组合问题。                                                        
For i = 1 To 5
排列组合问题。                                                            appear(i) 
= 0
排列组合问题。                                                        
Next
排列组合问题。
排列组合问题。                                                    
End If
排列组合问题。                                                    pre 
= t5
排列组合问题。                                                
Next
排列组合问题。
排列组合问题。                                            
End If
排列组合问题。                                            pre 
= t4
排列组合问题。                                        
Next
排列组合问题。                                        
排列组合问题。                                    
End If
排列组合问题。                                    pre 
= t3
排列组合问题。                                
Next
排列组合问题。
排列组合问题。                            
End If
排列组合问题。                        
End If
排列组合问题。                        pre 
= t2
排列组合问题。                    
Next
排列组合问题。
排列组合问题。                
End If
排列组合问题。                pre 
= t1 '还原pre的值
排列组合问题。
            Next
排列组合问题。
排列组合问题。        
End If
排列组合问题。
排列组合问题。        pre 
= 0 '还原pre的值
排列组合问题。
    Next
排列组合问题。    
排列组合问题。
排列组合问题。%
>

相关文章: