|  Sub a()
 Randomize
 
 Dim a(13) As Integer
 Dim earth As Integer
 Dim three As Integer
 Dim all As Integer
 Dim Knifee As Integer
 Dim Knifet As Integer
 
 n = 1
 
 For j = 1 To 10000
 
 Cells(n, 1) = "开始出刀"
 n = n + 1
 For i = 1 To 13
 a(i) = 1
 Next
 earth = 8
 three = 5
 all = 13
 Knifet = 0
 Knifee = 5
 dday = 1
 
 Do
 Do
 Knifet = Knifet + 1
 If Knifet = 4 Then Knifet = 1
 Loop Until a(Knifet) = 1                                                    //3体出刀人
 Do
 Knifee = Knifee + 1
 If Knifee = 9 Then Knifee = 6
 Loop Until a(Knifee) = 1                                                  //地球出刀人
 
 ke = Int(Rnd() * 13 + 1)
 Do Until ke <> Knifee And a(ke) = 1
 ke = Int(Rnd() * 13 + 1)
 Loop                                                                    //被地球人砍中
 kt = Int(Rnd() * 8 + 6)
 Do Until kt <> Knifet And a(kt) = 1
 kt = Int(Rnd() * 8 + 6)                                  //如果是大家都不跳阵营,kt=Int(Rnd() * 13 + 1)
 Loop
 a(ke) = 0
 Cells(n, 1) = Knifee & "刀了" & ke
 n = n + 1                                                          //cout<<endl;
 a(kt) = 0
 Cells(n, 1) = Knifet & "刀了" & kt
 n = n + 1
 If ke = kt Then
 all = all - 1
 If ke > 5 Then
 earth = earth - 1
 Else
 three = three - 1
 End If
 Else
 all = all - 2
 If ke > 5 Then
 earth = earth - 1
 Else
 three = three - 1
 End If
 If kt > 5 Then
 earth = earth - 1
 Else
 three = three - 1
 End If
 End If
 dday = dday + 1
 Loop Until (a(1) = 0 And a(2) = 0 And a(3) = 0) Or (a(6) = 0 And a(7) = 0 And a(8) = 0) Or three - earth >= 3
 
 If three - earth >= 3 Then
 Cells(n, 1) = dday & "天,3体胜,人数比" & earth & ":" & three  //相当于 cout<<dday & "天,3体胜,人数比" & earth & ":" & three
 n = n + 2
 GoTo XX
 End If
 If a(1) = 0 And a(2) = 0 And a(3) = 0 And a(6) = 0 And a(7) = 0 And a(8) = 0 Then
 Cells(n, 1) = dday & "天,一起没刀,人数比" & earth & ":" & three
 n = n + 2
 GoTo XX
 End If
 If a(1) = 0 And a(2) = 0 And a(3) = 0 Then
 Cells(n, 1) = dday & "天,3体没刀,人数比" & earth & ":" & three
 n = n + 2
 GoTo XX
 End If
 If a(6) = 0 And a(7) = 0 And a(8) = 0 Then
 Cells(n, 1) = dday & "天,地球没刀,人数比" & earth & ":" & three
 n = n + 2
 GoTo XX
 End If
 MsgBox "代码出错"
 XX:
 
 Next
 
 End Sub
 |