Vorige Pagina About the Author

' Generates Center Crosses of order 10

' Tested with Office 2007 under Windows 7

Sub CntrCross10()

Dim a(100), b(100), c(100), a1(100), b1(100)

y = MsgBox("Blocked", 0, "CntrCross10")
End

n2 = 0: n3 = 0: n9 = 0: k1 = 1: k2 = 1
Sheets("Klad1").Select

'   Define Integers

    For i1 = 1 To 36
        a1(i1) = i1 + 32
        b1(a1(i1)) = a1(i1)
    Next i1
    m1 = 1: m2 = 36: s1 = 303

' Center Pairs

For j55 = 1 To 18 ''m1 To m2
If b(a1(j55)) = 0 Then b(a1(j55)) = a1(j55): c(55) = a1(j55) Else GoTo 550
a(55) = a1(j55)
    
a(46) = s1 / 3 - a(55)
If a(46) < a1(m1) Or a(46) > a1(m2) Then GoTo 460
If b1(a(46)) = 0 Then GoTo 460
If b(a(46)) = 0 Then b(a(46)) = a(46): c(46) = a(46) Else GoTo 460
    
For j56 = m1 To m2
If b(a1(j56)) = 0 Then b(a1(j56)) = a1(j56): c(56) = a1(j56) Else GoTo 560
a(56) = a1(j56)
    
a(45) = s1 / 3 - a(56)
If a(45) < a1(m1) Or a(45) > a1(m2) Then GoTo 450
If b1(a(45)) = 0 Then GoTo 450
If b(a(45)) = 0 Then b(a(45)) = a(45): c(45) = a(45) Else GoTo 450

' Center Cross 6 x 6, Vertcal Pairs

For j25 = m1 To m2
If b(a1(j25)) = 0 Then b(a1(j25)) = a1(j25): c(25) = a1(j25) Else GoTo 250
a(25) = a1(j25)
    
a(26) = s1 / 3 - a(25)
If a(26) < a1(m1) Or a(26) > a1(m2) Then GoTo 260
If b1(a(26)) = 0 Then GoTo 260
If b(a(26)) = 0 Then b(a(26)) = a(26): c(26) = a(26) Else GoTo 260

For j35 = m1 To m2
If b(a1(j35)) = 0 Then b(a1(j35)) = a1(j35): c(35) = a1(j35) Else GoTo 350
a(35) = a1(j35)
    
a(36) = s1 / 3 - a(35)
If a(36) < a1(m1) Or a(36) > a1(m2) Then GoTo 360
If b1(a(36)) = 0 Then GoTo 360
If b(a(36)) = 0 Then b(a(36)) = a(36): c(36) = a(36) Else GoTo 360

For j65 = m1 To m2
If b(a1(j65)) = 0 Then b(a1(j65)) = a1(j65): c(65) = a1(j65) Else GoTo 650
a(65) = a1(j65)
    
a(66) = s1 / 3 - a(65)
If a(66) < a1(m1) Or a(66) > a1(m2) Then GoTo 660
If b1(a(66)) = 0 Then GoTo 660
If b(a(66)) = 0 Then b(a(66)) = a(66): c(66) = a(66) Else GoTo 660

a(75) = s1 - a(25) - a(35) - a(45) - a(55) - a(65)
If a(75) < a1(m1) Or a(75) > a1(m2) Then GoTo 750
If b1(a(75)) = 0 Then GoTo 750
If b(a(75)) = 0 Then b(a(75)) = a(75): c(75) = a(75) Else GoTo 750

a(76) = s1 / 3 - a(75)
If a(76) < a1(m1) Or a(76) > a1(m2) Then GoTo 760
If b1(a(76)) = 0 Then GoTo 760
If b(a(76)) = 0 Then b(a(76)) = a(76): c(76) = a(76) Else GoTo 760

' Center Cross 6 x 6, Horizontal Pairs

For j53 = m1 To m2
If b(a1(j53)) = 0 Then b(a1(j53)) = a1(j53): c(53) = a1(j53) Else GoTo 530
a(53) = a1(j53)
    
a(43) = s1 / 3 - a(53)
If a(43) < a1(m1) Or a(43) > a1(m2) Then GoTo 430
If b1(a(43)) = 0 Then GoTo 430
If b(a(43)) = 0 Then b(a(43)) = a(43): c(43) = a(43) Else GoTo 430

For j54 = m1 To m2
If b(a1(j54)) = 0 Then b(a1(j54)) = a1(j54): c(54) = a1(j54) Else GoTo 540
a(54) = a1(j54)
    
a(44) = s1 / 3 - a(54)
If a(44) < a1(m1) Or a(44) > a1(m2) Then GoTo 440
If b1(a(44)) = 0 Then GoTo 440
If b(a(44)) = 0 Then b(a(44)) = a(44): c(44) = a(44) Else GoTo 440

For j57 = m1 To m2
If b(a1(j57)) = 0 Then b(a1(j57)) = a1(j57): c(57) = a1(j57) Else GoTo 570
a(57) = a1(j57)
    
a(47) = s1 / 3 - a(57)
If a(47) < a1(m1) Or a(47) > a1(m2) Then GoTo 470
If b1(a(47)) = 0 Then GoTo 470
If b(a(47)) = 0 Then b(a(47)) = a(47): c(47) = a(47) Else GoTo 470

a(58) = s1 - a(53) - a(54) - a(55) - a(56) - a(57)
If a(58) < a1(m1) Or a(58) > a1(m2) Then GoTo 580
If b1(a(58)) = 0 Then GoTo 580
If b(a(58)) = 0 Then b(a(58)) = a(58): c(58) = a(58) Else GoTo 580

a(48) = s1 / 3 - a(58)
If a(48) < a1(m1) Or a(48) > a1(m2) Then GoTo 480
If b1(a(48)) = 0 Then GoTo 480
If b(a(48)) = 0 Then b(a(48)) = a(48): c(48) = a(48) Else GoTo 480

'  Complete 10 x 10 Cross, Horizontal

For j5 = m1 To m2
If b(a1(j5)) = 0 Then b(a1(j5)) = a1(j5): c(5) = a1(j5) Else GoTo 50
a(5) = a1(j5)
    
a(6) = s1 / 3 - a(5)
If a(6) < a1(m1) Or a(6) > a1(m2) Then GoTo 60
If b1(a(6)) = 0 Then GoTo 60
If b(a(6)) = 0 Then b(a(6)) = a(6): c(6) = a(6) Else GoTo 60

For j15 = m1 To m2
If b(a1(j15)) = 0 Then b(a1(j15)) = a1(j15): c(15) = a1(j15) Else GoTo 150
a(15) = a1(j15)
    
a(16) = s1 / 3 - a(15)
If a(16) < a1(m1) Or a(16) > a1(m2) Then GoTo 160
If b1(a(16)) = 0 Then GoTo 160
If b(a(16)) = 0 Then b(a(16)) = a(16): c(16) = a(16) Else GoTo 160

For j85 = m1 To m2
If b(a1(j85)) = 0 Then b(a1(j85)) = a1(j85): c(85) = a1(j85) Else GoTo 850
a(85) = a1(j85)
    
a(86) = s1 / 3 - a(85)
If a(86) < a1(m1) Or a(86) > a1(m2) Then GoTo 860
If b1(a(86)) = 0 Then GoTo 860
If b(a(86)) = 0 Then b(a(86)) = a(86): c(86) = a(86) Else GoTo 860

a(95) = 2 * s1 / 3 - a(5) - a(15) - a(85)
If a(95) < a1(m1) Or a(95) > a1(m2) Then GoTo 950
If b1(a(95)) = 0 Then GoTo 950
If b(a(95)) = 0 Then b(a(95)) = a(95): c(95) = a(95) Else GoTo 950

a(96) = s1 / 3 - a(95)
If a(96) < a1(m1) Or a(96) > a1(m2) Then GoTo 960
If b1(a(96)) = 0 Then GoTo 960
If b(a(96)) = 0 Then b(a(96)) = a(96): c(96) = a(96) Else GoTo 960

'  Complete 10 x 10 Cross, Vertical

For j51 = m1 To m2
If b(a1(j51)) = 0 Then b(a1(j51)) = a1(j51): c(51) = a1(j51) Else GoTo 510
a(51) = a1(j51)
    
a(41) = s1 / 3 - a(51)
If a(41) < a1(m1) Or a(41) > a1(m2) Then GoTo 410
If b1(a(41)) = 0 Then GoTo 410
If b(a(41)) = 0 Then b(a(41)) = a(41): c(41) = a(41) Else GoTo 410

For j52 = m1 To m2
If b(a1(j52)) = 0 Then b(a1(j52)) = a1(j52): c(52) = a1(j52) Else GoTo 520
a(52) = a1(j52)
    
a(42) = s1 / 3 - a(52)
If a(42) < a1(m1) Or a(42) > a1(m2) Then GoTo 420
If b1(a(42)) = 0 Then GoTo 420
If b(a(42)) = 0 Then b(a(42)) = a(42): c(42) = a(42) Else GoTo 420

For j59 = m1 To m2
If b(a1(j59)) = 0 Then b(a1(j59)) = a1(j59): c(59) = a1(j59) Else GoTo 590
a(59) = a1(j59)
    
a(49) = s1 / 3 - a(59)
If a(49) < a1(m1) Or a(49) > a1(m2) Then GoTo 490
If b1(a(49)) = 0 Then GoTo 490
If b(a(49)) = 0 Then b(a(49)) = a(49): c(49) = a(49) Else GoTo 490

a(60) = 2 * s1 / 3 - a(51) - a(52) - a(59)
If a(60) < a1(m1) Or a(60) > a1(m2) Then GoTo 600
If b1(a(60)) = 0 Then GoTo 600
If b(a(60)) = 0 Then b(a(60)) = a(60): c(60) = a(60) Else GoTo 600

a(50) = s1 / 3 - a(60)
If a(50) < a1(m1) Or a(50) > a1(m2) Then GoTo 500
If b1(a(50)) = 0 Then GoTo 500
If b(a(50)) = 0 Then b(a(50)) = a(50): c(50) = a(50) Else GoTo 500


                           n9 = n9 + 1

                           GoSub 2650 'Print results (squares)
'                          GoSub 2645 'Print results (selected numbers)
                           Erase b, c: GoTo 550   'Print only first square

    
    b(c(50)) = 0: c(50) = 0
500 b(c(60)) = 0: c(60) = 0
600 b(c(49)) = 0: c(49) = 0
490 b(c(59)) = 0: c(59) = 0
590 Next j59

    b(c(42)) = 0: c(42) = 0
420 b(c(52)) = 0: c(52) = 0
520 Next j52
    
    b(c(41)) = 0: c(41) = 0
410 b(c(51)) = 0: c(51) = 0
510 Next j51
    
    b(c(96)) = 0: c(96) = 0
960 b(c(95)) = 0: c(95) = 0
950 b(c(86)) = 0: c(86) = 0
860 b(c(85)) = 0: c(85) = 0
850 Next j85

    b(c(16)) = 0: c(16) = 0
160 b(c(15)) = 0: c(15) = 0
150 Next j15
    
    b(c(6)) = 0: c(6) = 0
60 b(c(5)) = 0: c(5) = 0
50 Next j5
    
    b(c(48)) = 0: c(48) = 0
480 b(c(58)) = 0: c(58) = 0
580 b(c(47)) = 0: c(47) = 0
470 b(c(57)) = 0: c(57) = 0
570 Next j57

    b(c(44)) = 0: c(44) = 0
440 b(c(54)) = 0: c(54) = 0
540 Next j54

    b(c(43)) = 0: c(43) = 0
430 b(c(53)) = 0: c(53) = 0
530 Next j53

    b(c(76)) = 0: c(76) = 0
760 b(c(75)) = 0: c(75) = 0
750 b(c(66)) = 0: c(66) = 0
660 b(c(65)) = 0: c(65) = 0
650 Next j65
    
    b(c(36)) = 0: c(36) = 0
360 b(c(35)) = 0: c(35) = 0
350 Next j35
    
    b(c(26)) = 0: c(26) = 0
260 b(c(25)) = 0: c(25) = 0
250 Next j25
    
    b(c(45)) = 0: c(45) = 0
450 b(c(56)) = 0: c(56) = 0
560 Next j56
    
    b(c(46)) = 0: c(46) = 0
460 b(c(55)) = 0: c(55) = 0
550 Next j55
    
    t2 = Timer
    
    t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions for sum" + Str(s1)
    y = MsgBox(t10, 0, "Routine CntrCross10")

End

'    Print results (selected numbers)

2645 For i1 = 1 To 100
         Cells(n9, i1).Value = a(i1)
     Next i1
    
     Return

'    Print results (squares)

2650 n2 = n2 + 1
     If n2 = 4 Then
         n2 = 1: k1 = k1 + 11: k2 = 1
     Else
         If n9 > 1 Then k2 = k2 + 11
     End If
     
     Cells(k1, k2 + 1).Select
     Cells(k1, k2 + 1).Font.Color = -4165632
     Cells(k1, k2 + 1).Value = n9
    
     i3 = 0
     For i1 = 1 To 10
         For i2 = 1 To 10
             i3 = i3 + 1
             Cells(k1 + i1, k2 + i2).Value = a(i3)
         Next i2
     Next i1
    
     Return

End Sub

Vorige Pagina About the Author