pascal把文件程序改为非文件程序或告诉我怎么运行

来源:百度知道 编辑:UC知道 时间:2024/06/17 00:53:12
书上的填图问题:
const max=10;
type gradat=array[1.. max,1..max]of byte;
var data:gradat;
n:byte;
color:array[1..max]of byte;
total:integer;
procedure getdata;
var name:string[12];
fdat:text;
i,j:byte;
begin
write('use which file?');
readln(name);
assign(fdat,name);
reset(fdat);
read(fdat,n);
read(fdat,data[i,j]);
for i:=1 to n do
for j:=1 to n do
begin
for j:=1 to n do write(data[i,j]:5);
writeln;
end;
writeln;
end;
function colorsame(s:byte):boolean;
var i:byte;
begin
colorsame:=false;
for i:=1 to s-1 do
if (data[i,s]=1) and (color[i]=color[s]) then colorsame:=true;
end;
procedure print;
var i:byte;
begin
for i:=1 to n do write(color[i]:2);
inc(total);
writeln('con:',total);
end;
procedure try(s:byte);

assign(fdat,name);
reset(fdat);
把这两句删了。。

const max=10;
type gradat=array[1.. max,1..max]of byte;
var data:gradat;
n:byte;
color:array[1..max]of byte;
total:integer;
procedure getdata;
var name:string[12];
i,j:byte;
begin
write('use which file?');
readln(name);
read(n);
read(data[i,j]);
for i:=1 to n do
for j:=1 to n do
begin
for j:=1 to n do write(data[i,j]:5);
writeln;
end;
writeln;
end;
function colorsame(s:byte):boolean;
var i:byte;
begin
colorsame:=false;
for i:=1 to s-1 do
if (data[i,s]=1) and (color[i]=color[s]) then colorsame:=true;
end;
procedure print;
var i:byte;
begin
for i:=1 to n do write(color[i]:2);
inc(total);
writeln('con:',total);
end;
procedure try(s:byte);
var i:byte;
begin
if s>7 then print else