4. 删除其它字符
program ex_4;
var
st : string;
i, len : integer;
begin
readln(st);
len := length(st);
i := len;
while i >= 1 do
begin
if (st[i] < 'A') or ((st[i] > 'Z') and (st[i] < 'a')) or (st[i] > 'z') then
delete(st, i, 1);
i := i-1;
end;
writeln(st);
readln;
end.
program ex_4;
var
st : string;
i, j, len : integer;
begin
readln(st);
len := length(st);
j := 1;
for i := 1 to len do
if ((st[i] >= 'A') and (st[i] <= 'Z')) or ((st[i] >= 'a')) and (st[i] <= 'z') then
begin
if (i <> j) then
st[j] := st[i];
j := j+1;
end;
st[0] := chr(j-1);
writeln(st);
readln;
end.
var
st : string;
i, len : integer;
begin
readln(st);
len := length(st);
i := len;
while i >= 1 do
begin
if (st[i] < 'A') or ((st[i] > 'Z') and (st[i] < 'a')) or (st[i] > 'z') then
delete(st, i, 1);
i := i-1;
end;
writeln(st);
readln;
end.
program ex_4;
var
st : string;
i, j, len : integer;
begin
readln(st);
len := length(st);
j := 1;
for i := 1 to len do
if ((st[i] >= 'A') and (st[i] <= 'Z')) or ((st[i] >= 'a')) and (st[i] <= 'z') then
begin
if (i <> j) then
st[j] := st[i];
j := j+1;
end;
st[0] := chr(j-1);
writeln(st);
readln;
end.


浙公网安备 33010602011771号