Az alábbi letöltési lehetőségek közül választhatsz: (
segítség)
Típus: text/plain
Tartalmaz szöveget
Karakterkódolás: us-ascii
Méret: 2 KB
program azt;
const en=6;
sc=10;
type tab=array[0..en+1,0..en+1] of char;
var t:text; i,j:longint; s:ansistring;
ko:tab; a:array[1..3000000] of tab; ke,ve:longint;
b:array[1..3000000] of longint; ma:longint;
function joe(kii:longint):boolean;
var ii,jj:longint;
begin
joe:=true;
for ii:=1 to en do begin
for jj:=1 to en do begin
if a[kii][ii,jj]='L' then joe:=false;
end; end; end;
function ed(kii:longint):boolean;
var ii,jj:longint;
begin
ed:=true;
for ii:=1 to en do begin
for jj:=1 to en do begin
if ko[ii,jj]<>a[kii][ii,jj] then ed:=false;
end; end; end;
function volt(kii:longint):boolean;
var ii:longint;
begin
volt:=false;
for ii:=1 to kii do if ed(ii) then volt:=true;
end;
begin
assign(t,'azt.be'); reset(t);
for i:=1 to en+2 do begin readln(t,s);
for j:=1 to en+2 do ko[i-1,j-1]:=s[j]
end; close(t);
a[1]:=ko; ke:=1; ve:=1; b[1]:=0;
while (ke<=ve) and (joe(ve)=false) do begin
for i:=1 to en do for j:=1 to en do begin
if (a[ke][i,j]='J') and (a[ke][i+1,j+1]='B') then begin
ko:=a[ke]; ko[i,j]:='L'; ko[i,j+1]:='L'; ko[i+1,j]:='F'; ko[i+1,j+1]:='F';
if volt(ve)=false then begin inc(ve); a[ve]:=ko; b[ve]:=ke; end;
end;
if (a[ke][i,j]='L') and (a[ke][i+1,j+1]='F') then begin
ko:=a[ke]; ko[i,j]:='J'; ko[i,j+1]:='B'; ko[i+1,j]:='J'; ko[i+1,j+1]:='B';
if volt(ve)=false then begin inc(ve); a[ve]:=ko; b[ve]:=ke; end;
end;
end;
inc(ke);
end;
assign(t,'azt.svg'); rewrite(t);
writeln(t,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">');
writeln(t,'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">');
ma:=1;
ke:=ve;
while ke>0 do begin for i:=1 to en do for j:=1 to en do begin
if a[ke][i,j]='J' then begin
write(t,'<rect x="',j*sc+sc,'" y="',(ma+i)*sc,'" width="',sc*2);
writeln(t,'" height="',sc,'" style="fill:red;stroke:black;stroke-width:2;"/>');
end;
if a[ke][i,j]='L' then begin
write(t,'<rect x="',j*sc+sc,'" y="',(ma+i)*sc,'" width="',sc);
writeln(t,'" height="',sc*2,'" style="fill:red;stroke:black;stroke-width:2;"/>');
end;
end; ma:=ma+en+1; ke:=b[ke]; end;
writeln(t,'</svg>');
close(t);
end.