Dennnhhhickk

Untitled

Oct 9th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. program Project6;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6. SysUtils;
  7.  
  8. const
  9. MAXIN = 11;
  10.  
  11. var
  12. n, i, j, k: integer;
  13. a: array [0..MAXIN, 0..MAXIN] of integer;
  14.  
  15. procedure wiwod();
  16. var
  17. i, j: integer;
  18. time: array [-1..MAXIN] of integer;
  19. begin
  20. for i := 1 to n do
  21. time[i] := 0;
  22.  
  23. for i := 1 to n do
  24. for j := 1 to n do
  25. inc(time[a[i][j]]);
  26.  
  27. //for i := 1 to n do
  28. //if (time[i] <> n) then
  29. //exit;
  30.  
  31. for i := 1 to n do
  32. begin
  33. for j := 1 to n - 1 do
  34. write(a[i][j], ' ');
  35. writeln(a[i][n]);
  36. end;
  37.  
  38. readln;
  39. readln;
  40. end;
  41.  
  42. procedure rec(x, y: integer);
  43. var
  44. i, j: integer;
  45. used: array [0..MAXIN] of boolean;
  46. begin
  47. //inc(k);
  48. //if (k = 10001) then
  49. //writeln(K);
  50. //writeln(a[x][y], ' ',x, ' ',y);
  51. for i := 1 to n do
  52. used[i] := true;
  53.  
  54. for i := 1 to n do
  55. begin
  56. used[a[x][i]] := false;
  57. used[a[i][y]] := false;
  58. end;
  59.  
  60. if (a[x][y] <> 0) then
  61. if (x = n) and (y = n) then
  62. wiwod
  63. else
  64. if (y = n) then
  65. rec(x + 1, 1)
  66. else
  67. rec(x, y + 1)
  68. else
  69. for i := 1 to n do
  70. if (used[i]) then
  71. begin
  72. a[x][y] := i;
  73. if (x = n) and (y = n) then
  74. wiwod
  75. else
  76. if (y = n) then
  77. rec(x + 1, 1)
  78. else
  79. rec(x, y + 1);
  80. end;
  81. a[x][y] := 0;
  82. end;
  83.  
  84. begin
  85. //k := 0;
  86. readln(n);
  87.  
  88. for i := 1 to n do
  89. for j := 1 to n do
  90. read(a[i][j]);
  91.  
  92. rec(1, 1);
  93. readln;readln;readln;readln;
  94. end.
  95.  
  96. 10
  97. 0 0 0 0 0 0 0 0 0 0
  98. 0 0 0 0 0 0 0 0 0 0
  99. 0 0 0 0 0 0 0 0 0 0
  100. 0 0 0 0 0 0 0 0 0 0
  101. 0 0 0 0 0 0 0 0 0 0
  102. 0 0 0 0 0 0 0 0 0 0
  103. 0 0 0 0 0 0 0 0 0 0
  104. 0 0 0 0 0 0 0 0 0 0
  105. 0 0 0 0 0 0 0 0 0 0
  106. 0 0 0 0 0 0 0 0 0 0
Advertisement
Add Comment
Please, Sign In to add comment