主题:[讨论]关于一笔画问题
const n=6;
var a:array[1..n,1..n]of integer;
b:array[1..n]of integer;
w,k,m,j,i,h,f:integer;
begin
assign(input,'b.in');
assign(output,'b.out');
reset(input);rewrite(output);
k:=1;h:=0;
for i:=1 to n do
begin
b[i]:=0;
for j:=1 to n do
begin
read(a[i,j]);
b[i]:=b[i]+a[i,j];
end;
if (b[i] mod 2=1)
then begin
inc(h);
if k=1 then k:=i
else w:=i;
end;
end;
if h>2 then
begin
writeln('NO SOLUTION');
exit;
end;
write(k);
repeat
i:=1;f:=b[i]; f:=a[k,i];
while ( (b[i]=1) or (f=0)and(i<=n)) do begin inc(i);f:=a[k,i];end;
if i<=n then begin
write('--->',i);
a[k,i]:=0;
a[i,k]:=0;
b[k]:=b[k]-1;
b[i]:=b[i]-1;
k:=i;
end;
until i=n+1;
writeln('--->',w);close(input);close(output);
end.
输出文件0 1 0 1 1 1 1 0 1 0 1 0 0 1 0 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 0 1 1 0 0
朋友们好
这个程序在TP里面呢感运行,但是在FREEPASCAL里面却不行,请帮忙找找原因
var a:array[1..n,1..n]of integer;
b:array[1..n]of integer;
w,k,m,j,i,h,f:integer;
begin
assign(input,'b.in');
assign(output,'b.out');
reset(input);rewrite(output);
k:=1;h:=0;
for i:=1 to n do
begin
b[i]:=0;
for j:=1 to n do
begin
read(a[i,j]);
b[i]:=b[i]+a[i,j];
end;
if (b[i] mod 2=1)
then begin
inc(h);
if k=1 then k:=i
else w:=i;
end;
end;
if h>2 then
begin
writeln('NO SOLUTION');
exit;
end;
write(k);
repeat
i:=1;f:=b[i]; f:=a[k,i];
while ( (b[i]=1) or (f=0)and(i<=n)) do begin inc(i);f:=a[k,i];end;
if i<=n then begin
write('--->',i);
a[k,i]:=0;
a[i,k]:=0;
b[k]:=b[k]-1;
b[i]:=b[i]-1;
k:=i;
end;
until i=n+1;
writeln('--->',w);close(input);close(output);
end.
输出文件0 1 0 1 1 1 1 0 1 0 1 0 0 1 0 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 0 1 1 0 0
朋友们好
这个程序在TP里面呢感运行,但是在FREEPASCAL里面却不行,请帮忙找找原因