TIAO.PAS 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. uses crt;
  2. const
  3. ch : array[0..1]of char = ('.','*');
  4. var
  5. a : array[0..100,0..100]of byte;
  6. n,i,j,k,k1,num : integer;
  7. procedure print;
  8. var ii,jj : integer;
  9. begin
  10. clrscr;
  11. inc(num); writeln('No.',num);
  12. for ii:=0 to n+1 do
  13. begin
  14. for jj:=0 to n+1 do
  15. write(ch[a[ii,jj]],' ');
  16. writeln;
  17. end;
  18. write('Press <ENTER>...');
  19. readln;
  20. end;
  21. procedure l(t1,t2:integer);
  22. begin
  23. a[t1,t2-1]:=1; a[t1,t2]:=0; a[t1,t2+1]:=0;
  24. print;
  25. a[t1+1,t2]:=0; a[t1+2,t2]:=0; a[t1,t2]:=1;
  26. print;
  27. a[t1,t2-1]:=0; a[t1,t2]:=0; a[t1,t2+1]:=1;
  28. print;
  29. end;
  30. procedure h(t1,t2:integer);
  31. begin
  32. a[t1,t2]:=0;a[t1+1,t2]:=0;a[t1-1,t2]:=1;
  33. print;
  34. a[t1,t2+1]:=0;a[t1,t2+2]:=0;a[t1,t2]:=1;
  35. print;
  36. a[t1-1,t2]:=0;a[t1,t2]:=0;a[t1+1,t2]:=1;
  37. print;
  38. end;
  39. procedure Mo2(t1,t2:integer);
  40. begin
  41. a[t1,t2]:=0;a[t1+1,t2]:=0;a[t1+2,t2]:=1;print;
  42. a[t1,t2+1]:=0;a[t1+1,t2+1]:=0;a[t1+2,t2+1]:=1;print;
  43. a[t1+2,t2]:=0;a[t1+2,t2+1]:=0;a[t1+2,t2+2]:=1;print;
  44. a[t1,t2+2]:=0;a[t1,t2+3]:=0;a[t1,t2+1]:=1;print;
  45. a[t1+2,t2+2]:=0;a[t1+1,t2+2]:=0;a[t1,t2+2]:=1;print;
  46. a[t1,t2+1]:=0;a[t1,t2+2]:=0;a[t1,t2+3]:=1;print;
  47. end;
  48. begin
  49. clrscr;
  50. write('N='); readln(n);
  51. if n mod 3 = 0 then begin write('No Way!');readln;halt;end;
  52. num:=0;
  53. fillchar(a,sizeof(a),0);
  54. for i:=1 to n do
  55. for j:=1 to n do
  56. a[i,j]:=1;
  57. print;
  58. k1:=n div 3;
  59. if n mod 3 = 1 then dec(k1);
  60. for i:=1 to k1 do
  61. for j:=1 to n-3 do
  62. l((i-1)*3+1,j);
  63. for i:=1 to k1*3 do h(i,n-2);
  64. case n mod 3 of
  65. 1:begin
  66. for i:=1 to k1+1 do h(3*k1+1,(i-1)*3+1);
  67. for i:=1 to n-2 do l(3*k1+2,i);
  68. a[n,n]:=0; a[n,n-1]:=0; a[n,n-2]:=1; print;
  69. a[n-1,n]:=0; a[n-1,n-1]:=0; a[n-1,n-2]:=1; print;
  70. a[n,n-2]:=0; a[n-1,n-2]:=0; a[n-2,n-2]:=1; print;
  71. a[n-3,n]:=0; a[n-2,n]:=0; a[n-1,n]:=1; print;
  72. a[n-2,n-2]:=0; a[n-2,n-1]:=0; a[n-2,n]:=1; print;
  73. a[n-1,n]:=0; a[n-2,n]:=0; a[n,n]:=1; print;
  74. end;
  75. 2:begin
  76. for i:=1 to k1 do
  77. mo2(3*k1+1,(i-1)*3+1);
  78. a[3*k1+1,3*k1+1]:=0;a[3*k1+2,3*k1+1]:=0;a[3*k1,3*k1+1]:=1;print;
  79. a[3*k1+1,3*k1+2]:=0;a[3*k1+2,3*k1+2]:=0;a[3*k1,3*k1+2]:=1;print;
  80. a[3*k1,3*k1+2]:=0;a[3*k1,3*k1+2]:=0;a[3*k1,3*k1]:=1;print;
  81. end;
  82. end;
  83. end.