给定"A","B","C","D",编程打印A(4,4)=24和A(4,2)=12所有的排列方式

 Option Explicit
Dim ss As String        '最终生成的字符串
Dim tt As Integer       '生成结果的个数
Private Sub Command1_Click()
Dim i As Integer, j As Integer, m As Integer, n As Integer
  Cls             '清屏
  tt = 0
  Print "-----------------------------------"
  For i = 1 To 4
    For j = 1 To 4
      For m = 1 To 4
        For n = 1 To 4
            If i + j + m + n = 10 And i <> j And i <> m And i <> n And j <> m And j <> n And m <> n Then
                ss = sort(i) & sort(j) & sort(m) & sort(n)
                tt = tt + 1
                Print ss
           End If
        Next
      Next
    Next
  Next
  Print "----------------------------------"
  Print "对于A(4,4),一共有"; tt; "种方法"
  Print "----------------------------------"
End Sub

Public Function sort(x As Integer) As String
 Dim i As Integer
 Dim s As String
 For i = 1 To x
  s = Chr(64 + x)   '获取这个字母 ,字母A的ASCII码为65

 Next
 sort = s  '返回这个字母,以A开始的字母
End Function

Private Sub Command2_Click()
Form2.Show
End Sub
'要把FORM1的AutoRecorddraw设为真

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值