0
点赞
收藏
分享

微信扫一扫

POJ 1951(空串特判)

两岁时就很帅 2022-10-25 阅读 22


这题的教训是 要特判空串


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.





举报

相关推荐

0 条评论