1 struct CSPoint 2 { 3 public int x; 4 public int y; 5 } 6 7 class othercsHorse 8 { 9 int[] DeltaX ={ -2, -1, 1, 2, 2, 1, -1, -2 }; 10 int[] DeltaY ={ 1, 2, 2, 1, -1, -2, -2, -1 }; 11 int[,] Game = new int[12, 12]; 12 CSPoint[] csPoint = new CSPoint[64]; 13 int step; 14 int ResultCount; 1516 public othercsHorse() 17 { 18 for (int i = 0; i < 12; i++) 19 { 20 Game[i, 0] = -1; 21 Game[i, 11] = -1; 22 Game[0, i] = -1; 23 Game[11, i] = -1; 24 Game[i, 1] = -1; 25 Game[i, 10] = -1; 26 Game[1, i] = -1; 27 Game[10, i] = -1; 28 } 29 step=0; 30 csPoint[step].x=2; 31 csPoint[step].y=2; 32 Game[csPoint[step].x, csPoint[step].y] = 1; 33 } 3435 public void OutputResult() 36 { 37 ResultCount++; 38 Console.WriteLine("Result:{0}", ResultCount); 39 for (int i = 2; i < 10; i++) 40 { 41 for (int j = 2; j < 10; j++) 42 { 43 Console.Write("{0}{1} ", (Game[i, j] < 10)?" ":"", Game[i, j].ToString()); 44 } 4546 Console.WriteLine(); 47 } 48 Console.WriteLine(); 49 } 5051 public void Start() 52 { 53 int NextX, NextY; 54 for (int i = 0; i < 8; i++) 55 { 56 NextX = csPoint[step].x + DeltaX[i]; 57 NextY = csPoint[step].y + DeltaY[i]; 58 if (Game[NextX, NextY] == 0) 59 { 60 Game[NextX, NextY] = ++step + 1; 61 csPoint[step].x = NextX; 62 csPoint[step].y = NextY; 63 if (step == 63) 64 { 65 OutputResult(); 66 } 6768 Start(); 69 } 70 } 7172 Game[csPoint[step].x,csPoint[step].y] = 0; 73 --step; 74 } 7576 } 77