讨论 / 为什么错了?
roy12 2010-07-12 19:22:00
点我顶贴 收藏 删除
var q:array[1..10000]of string[20];

m:array[1..10000]of longint;

s1,s2:string[20]; c:char;

a:array[1..6,1..2]of string[20];

i,j,k,l,r,n,len:longint;

begin

s1:=’’;

s2:=’’;

repeat

read(c);

if c<>’ ’ then s1:=s1+c;

until c=’ ’;

readln(s2);

for i:=1 to 6 do

for j:=1 to 2 do

a[i,j]:=’’;

i:=0;

while not seekeof do

begin

inc(i);

repeat

read(c);

if c<>’ ’ then a[i,1]:=a[i,1]+c;

until c=’ ’;

readln(a[i,2]);

end;

n:=i;

q[1]:=s1;

l:=1; r:=1;

for i:=1 to 10000 do

m[i]:=0;

repeat

for i:=1 to n do

begin

len:=length(a[i,1]);

for j:=1 to length(q[l])-length(a[i,1])+1 do

begin

s1:=copy(q[l],j,length(a[i,1]));

if (a[i,1]=s1)and(m[l]<10) then

begin

inc(r);

q[r]:=q[l];

m[r]:=m[l]+1;

delete(q[r],j,length(a[i,1]));

insert(a[i,2],q[r],j);

if q[r]=s2 then begin writeln(m[r]); exit; end;

end;

end;

end;

inc(l);

until (l>r);

writeln(’NO ANSWER!’);

end.

第五个点和第十个点。。。我输出no answer错了//

为什么啊?

#1 wjywbs@2008-08-08 03:28:00
回复 删除
3和8点为no answer
#2 sheng_1230@2008-08-08 17:59:00
回复 删除
不知道

#3 无限容量@2008-10-27 06:25:00
回复 删除
很神奇
#4 yangdong@2010-07-12 19:22:00
回复 删除
lz 考虑一个模式串

在主串中出现多次的情况否?

估计是这

查看更多回复
提交回复