fork download
  1. Program abc;
  2.  
  3. const
  4. Width = 78;
  5. Height = 25;
  6. WALL = 1;
  7. FLOOR = 0;
  8.  
  9. var
  10. x,y:Integer;
  11. map : array [0 .. Width , 0 .. Height] of Integer;
  12.  
  13. Type
  14. map_gen = array[0..Width,0..Height] of Integer;
  15. ////////////////////////////////////////////////////////////////////////////////
  16. Function floodfill(x,y,old_color,new_color:Integer; map : map_gen) : Integer;
  17. var
  18. x2,y2:Integer;
  19. begin
  20. if (x < 0) or (y < 0) or (x > Width) or (y > Height) then Exit();
  21. if map[x,y] <> old_color then Exit();
  22. map[x,y] := new_color;
  23. for x2 := -1 to 1 do
  24. begin
  25. for y2 := -1 to 1 do
  26. begin
  27. floodfill(x + x2,y + y2,old_color,new_color,map);
  28. end;
  29. end;
  30. end;
  31. ////////////////////////////////////////////////////////////////////////////////
  32. begin
  33. for x := 0 to Width do
  34. for y := 0 to Height do
  35. map[x,y] := FLOOR;
  36.  
  37. map[10,10] := WALL;
  38. map[10,11] := WALL;
  39. map[10,9] := WALL;
  40. map[11,9] := WALL;
  41. map[11,11] := WALL;
  42. map[12,9] := WALL;
  43. map[12,10] := WALL;
  44. map[12,11] := WALL;
  45.  
  46. floodfill(5,5,FLOOR,WALL,map);
  47.  
  48. for y := 0 to Height do
  49. begin
  50. writeln();
  51. for x := 0 to Width do
  52. begin
  53. Write(map[x,y]);
  54. end;
  55. end;
  56. readln();
  57. end.
  58.  
Runtime error #stdin #stdout 0.02s 8320KB
stdin
Standard input is empty
stdout
Standard output is empty