var a:array[0..32767]of char;
t:integer;
l:string;
function find(ch:char;h:integer):integer;
var i:integer;
begin
if ch=’[’ then
begin
i:=h;
while a[i]<>’]’ do
inc(i);
end else
begin
i:=h;
while a[i]<>’}’ do
inc(i);
end;
find:=i;
end;
procedure pd;
var j:char;
p,q,i,k,t1,t2,len,code:integer;
s: set of char;
l1:string;
begin
p:=1; q:=1;
while q<length(l) do
begin
s:=[]; l1:=’’; t1:=0; t2:=0;
if a[p]=’[’ then
begin
t1:=find(’[’,p);
for i:=p+1 to t1-1 do
if a[i]<>’-’ then s:=s+[a[i]]
else
for j:=a[i-1] to a[i+1] do
s:=s+[j];
len:=1;
if a[t1+1]=’{’ then
begin
t2:=find(’{’,t1+1);
for k:=t1+2 to t2-1 do
l1:=l1+a[k];
val(l1,len,code);
end;
for i:=q to q+len-1 do
if not (l[i] in s) then
begin
writeln(’Boring String Matching...’);
exit;
end;
if t2<>0 then p:=t2+1
else p:=t1+1;
q:=q+len;
end else
begin
if a[p]=l[q] then
begin inc(p); inc(q); end
else
begin
writeln(’Boring String Matching...’);
exit;
end;
end;
end;
writeln(’Regular Expression is Fun!’);
end;
begin
t:=0;
while not eoln do
begin
inc(t);
read(a[t]);
end;
readln(l);
while not eof do
begin
readln(l);
pd;
end;
end.
某一位的判断有两种情况,是’[’和是普通字符,普通字符直接比较就好了,假如是’[’的话再判断’]’后面是否还有’{}’如果有的话要比较的字串就要比较花括号里的数字位的长度,否则就比较一位,然后呢’[]’里的内容就放到一个集合里(注意判断’-’)然后再比较就好了......