POJ 1951(空串特判)

内容目录

这题的教训是 要特判空串

Program P1951;
var
   s:string;
   len,i,j:longint;
   b:array[0..10000] of boolean;
function isdight(x:longint):boolean;
begin
   if (x>=65) and (x<=90) then exit(false);
   if (x>=97) and (x<=122) then exit(false);
   exit(true);

end;
begin
   readln(s);
   fillchar(b,sizeof(b),false);
   b[ord('a')]:=true;
   b[ord('e')]:=true;
   b[ord('i')]:=true;
   b[ord('o')]:=true;
   b[ord('u')]:=true;
   b[ord('A')]:=true;
   b[ord('E')]:=true;
   b[ord('I')]:=true;
   b[ord('O')]:=true;
   b[ord('U')]:=true;

   i:=1;
   while i<=length(s) do
   begin
      if b[ord(s[i])] and not(isdight(ord(s[i]))) then delete(s,i,1)
      else
      begin
         b[ord(s[i])]:=true;
         inc(i);

      end;
   end;


   while (s[1]=' ') and (length(s)>=1) do delete(s,1,1);
   while (s[length(s)]=' ') and (length(s)>=1) do delete(s,length(s),1);
   i:=pos('  ',s);
   while i<>0 do
   begin
      delete(s,i,1);
      i:=pos('  ',s);
   end;
   i:=pos(' .',s);
   while i<>0 do
   begin
      delete(s,i,1);
      i:=pos(' .',s);
   end;
   i:=pos(' ,',s);
   while i<>0 do
   begin
      delete(s,i,1);
      i:=pos(' ,',s);
   end;
   i:=pos(' ?',s);
   while i<>0 do
   begin
      delete(s,i,1);
      i:=pos(' ?',s);
   end;



   writeln(s);

end.