代码很挫、、、求改错
查看原帖
代码很挫、、、求改错
667
smallling楼主2013/9/30 21:01
var
 i,j,k,l,m,n,o,p,b,g:longint;
 s:string;
begin
 readln(s);
 while pos('boy',s)<>0 do
  begin
   l:=pos('boy',s);
   inc(b);
   delete(s,l,3);
  end;
 while pos('bo',s)<>0 do
  begin
   l:=pos('bo',s);
   inc(b);
   delete(s,l,2);
  end;
 while pos('oy',s)<>0 do
  begin
   l:=pos('oy',s);
   inc(b);
   delete(s,l,2);
  end;
 while pos('b',s)<>0 do
  begin
   l:=pos('b',s);
   inc(b);
   delete(s,l,1);
  end;
 while pos('o',s)<>0 do
  begin
   l:=pos('o',s);
   inc(b);
   delete(s,l,1);
  end;
 while pos('y',s)<>0 do
  begin
   l:=pos('y',s);
   inc(b);
   delete(s,l,1);
  end;
 writeln(b);
 while pos('girl',s)<>0 do
  begin
   l:=pos('girl',s);
   inc(g);
   delete(s,l,4);
  end;
 while pos('gir',s)<>0 do
  begin
   l:=pos('gir',s);
   inc(g);
   delete(s,l,3);
  end;
 while pos('irl',s)<>0 do
  begin
   l:=pos('irl',s);
   inc(g);
   delete(s,l,3);
  end;
 while pos('gi',s)<>0 do
  begin
   l:=pos('gi',s);
   inc(g);
   delete(s,l,2);
  end;
 while pos('ir',s)<>0 do
  begin
   l:=pos('ir',s);
   inc(g);
   delete(s,l,2);
  end;
 while pos('rl',s)<>0 do
  begin
   l:=pos('rl',s);
   inc(g);
   delete(s,l,2);
  end;
 while pos('g',s)<>0 do
  begin
   l:=pos('g',s);
   inc(g);
   delete(s,l,1);
  end;
 while pos('i',s)<>0 do
  begin
   l:=pos('i',s);
   inc(g);
   delete(s,l,1);
  end;
 while pos('r',s)<>0 do
  begin
   l:=pos('r',s);
   inc(g);
   delete(s,l,1);
  end;
 while pos('l',s)<>0 do
  begin
   l:=pos('l',s);
   inc(g);
   delete(s,l,1);
  end;
 writeln(g);
end.
2013/9/30 21:01
加载中...