用Pascal语言写一个程序,从字符串中将指定的字母排除掉

来源:百度知道 编辑:UC知道 时间:2024/05/28 13:15:36
用Pascal语言写一个程序,将字符串中的指定字母排除掉不予显示,例如:I love programming,输入 a m i;最后结果显示 love progrng
请高手赐教!!
Forget_World_:
能详细说明一下你的程序吗?我有些地方不太明白,能详细注释一下吗,万分感谢!会加分的!

var
s:array[1..1000] of char;
ch:char;
l,i,j,k:integer;
begin
read(s[1]);
i:=1;
while ord(s[i])<>13 do
begin
i:=i+1;
read(s[i]);
end;
readln;
read(ch);
while ord(ch)<>13 do
begin
for l:=1 to i do
if (s[l]=ch) and (ch<>' ') then s[l]:='@';
read(ch);
end;
for j:=1 to i do
if s[j]<>'@' then write(s[j]);
end.
测试过了
直接输入字母
再输入要去除的字母
不用输入个数

program nimo;
var
s:string;
t:char;
i,j,p:integer;
begin
readln(s);
readln(n);
for i:=1 to n do
begin
readln(a[i]);
p:=pos(t,s)
while p<>0 do
begin
delete(s,p,1);
p:=pos(t,s)
end;
end;
writeln(s);
end.
先输入I love programming
再输入 n
再输入 n个你不要的字母

<