这是一段代码:目的是从输入源文件中去掉注释,输出
program program1;
{$APPTYPE CONSOLE}
uses
SysUtils
var
ch:char;
state:(copy,comment);
begin
state:=copy;
while not eof do//不知道这个循环什么时候能结束,请教各位
begin
while not eoln do
begin
read(ch);
case state of
copy: if ch='{' then
state:=comment
else
write(ch);
comment: if ch='}' then
state:=copy;
end;
end;
readln;
writeln;
end;
end.
好象这个程序是输一行,拷贝一行,能不能整个文件全输完了,再一起拷啊?
program program1;
{$APPTYPE CONSOLE}
uses
SysUtils
var
ch:char;
state:(copy,comment);
begin
state:=copy;
while not eof do//不知道这个循环什么时候能结束,请教各位
begin
while not eoln do
begin
read(ch);
case state of
copy: if ch='{' then
state:=comment
else
write(ch);
comment: if ch='}' then
state:=copy;
end;
end;
readln;
writeln;
end;
end.
好象这个程序是输一行,拷贝一行,能不能整个文件全输完了,再一起拷啊?
各位高人,帮帮忙哦,,,
对于input文件怎样设置一个结束标志啊,
我这程序什么时候会遇上eof为true啊?
{$APPTYPE CONSOLE}
uses
SysUtils;
var
ch:char;
state:(copy,comment);
begin
state:=copy;
while not eof do//不知道这个循环什么时候能结束,请教各位
begin
while not eoln do
begin
read(ch);
case state of
copy: if ch='{' then
state:=comment
else
write(ch);
comment: if ch='}' then
state:=copy;
end;
end;
readln;
writeln;
end;
end.
有两种状态,一种是拷贝状态,另外一种状态事复制状态。
state:(copy,comment);
有两种状态,一种是拷贝状态,另外一种状态是注释状态。
在拷贝状态时遇到‘{’就成为注释状态,在注释状态时遇上
‘}’就是拷贝状态。