Advertisement
diopractice

Untitled

Feb 25th, 2023
1,557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.63 KB | None | 0 0
  1. var i, j, count, x, y, num_elem: integer;
  2. var f: array [0..11, 0..11] of integer;  // Äîáàâèëè ðàìêó
  3.  
  4.  
  5. BEGIN
  6.     randomize();
  7.     num_elem := 10;
  8.     for i := 0 to num_elem + 1 do // Äîáàâèëè ðàìêó
  9.         for j := 0 to num_elem + 1 do // Äîáàâèëè ðàìêó
  10.             f[i,j] := 0;
  11.     count := 0;
  12.     while (count < 10) do
  13.     begin
  14.         x := random(num_elem) + 1;
  15.         y := random(num_elem) + 1;
  16.         if f[x, y] + f[x - 1, y] + f[x + 1, y] + f[x, y - 1] + f[x, y + 1] = 0 then
  17.         begin
  18.              f[x, y] := 1;
  19.              count := count + 1;
  20.         end;
  21.     end;
  22. END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement