GAMERS.PAS 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. var
  2. n,k,ck,t,x3,y3,i,j,cnum:longint;
  3. num:array[0..520,0..520] of longint;
  4. procedure solve(ck,x1,y1,x2,y2,x3,y3:longint);
  5. var
  6. xm,ym,p:longint;
  7. begin
  8. xm:=(x1+x2) div 2;
  9. ym:=(y1+y2) div 2;
  10. if (x3<=xm) and (y3>ym) then p:=1;
  11. if (x3<=xm) and (y3<=ym) then p:=2;
  12. if (x3>xm) and (y3<=ym) then p:=3;
  13. if (x3>xm) and (y3>ym) then p:=4;
  14. if ck=1 then
  15. begin
  16. cnum:=cnum+1;
  17. case p of
  18. 1:begin
  19. num[xm,ym]:=cnum;
  20. num[xm+1,ym]:=cnum;
  21. num[xm+1,ym+1]:=cnum;
  22. end;
  23. 2:begin
  24. num[xm,ym+1]:=cnum;
  25. num[xm+1,ym]:=cnum;
  26. num[xm+1,ym+1]:=cnum;
  27. end;
  28. 3:begin
  29. num[xm,ym]:=cnum;
  30. num[xm,ym+1]:=cnum;
  31. num[xm+1,ym+1]:=cnum;
  32. end;
  33. 4:begin
  34. num[xm,ym]:=cnum;
  35. num[xm,ym+1]:=cnum;
  36. num[xm+1,ym]:=cnum;
  37. end;
  38. end;
  39. end
  40. else
  41. begin
  42. cnum:=cnum+1;
  43. case p of
  44. 1:begin
  45. num[xm,ym]:=cnum;
  46. num[xm+1,ym]:=cnum;
  47. num[xm+1,ym+1]:=cnum;
  48. solve(ck-1,x1,ym+1,xm,y2,x3,y3);
  49. solve(ck-1,x1,y1,xm,ym,xm,ym);
  50. solve(ck-1,xm+1,y1,x2,ym,xm+1,ym);
  51. solve(ck-1,xm+1,ym+1,x2,y2,xm+1,ym+1);
  52. end;
  53. 2:begin
  54. num[xm,ym+1]:=cnum;
  55. num[xm+1,ym]:=cnum;
  56. num[xm+1,ym+1]:=cnum;
  57. solve(ck-1,x1,ym+1,xm,y2,xm,ym+1);
  58. solve(ck-1,x1,y1,xm,ym,x3,y3);
  59. solve(ck-1,xm+1,y1,x2,ym,xm+1,ym);
  60. solve(ck-1,xm+1,ym+1,x2,y2,xm+1,ym+1);
  61. end;
  62. 3:begin
  63. num[xm,ym]:=cnum;
  64. num[xm,ym+1]:=cnum;
  65. num[xm+1,ym+1]:=cnum;
  66. solve(ck-1,x1,ym+1,xm,y2,xm,ym+1);
  67. solve(ck-1,x1,y1,xm,ym,xm,ym);
  68. solve(ck-1,xm+1,y1,x2,ym,x3,y3);
  69. solve(ck-1,xm+1,ym+1,x2,y2,xm+1,ym+1);
  70. end;
  71. 4:begin
  72. num[xm,ym]:=cnum;
  73. num[xm,ym+1]:=cnum;
  74. num[xm+1,ym]:=cnum;
  75. solve(ck-1,x1,ym+1,xm,y2,xm,ym+1);
  76. solve(ck-1,x1,y1,xm,ym,xm,ym);
  77. solve(ck-1,xm+1,y1,x2,ym,xm+1,ym);
  78. solve(ck-1,xm+1,ym+1,x2,y2,x3,y3);
  79. end;
  80. end;
  81. end;
  82. end;
  83. begin
  84. n:=0; k:=0; ck:=0; t:=0; x3:=0; y3:=0; i:=0; j:=0; cnum:=0;
  85. fillchar(num,sizeof(num),0);
  86. readln(k);
  87. ck:=k;
  88. t:=1;
  89. for i:=1 to k do
  90. t:=t*2;
  91. n:=t;
  92. readln(x3,y3);
  93. num[x3,y3]:=0;
  94. cnum:=0;
  95. solve(ck,1,1,n,n,x3,y3);
  96. for i:=1 to n do
  97. begin
  98. for j:=1 to n-1 do
  99. write(num[i,j],' ');
  100. writeln(num[i,n]);
  101. end;
  102. end.