S
sdhjxue
Unregistered / Unconfirmed
GUEST, unregistred user!
//我想练习编写递归函数,请指出为什么会出错.
//目标:删除字符中的所有空格
function delspace(cstring: string):string;
var
i,j : integer;
ms : string;
begin
j := length(cstring);
i := pos(' ',cstring);
if i > 0 then
begin
ms := leftstr(cstring,i-1)+rightstr(cstring,j-i);//leftstr、rightstr为自定义取左、右字符串函数
result := ms;
ms := delspace(ms);
end
else
result := cstring;
end;
//目标:删除字符中的所有空格
function delspace(cstring: string):string;
var
i,j : integer;
ms : string;
begin
j := length(cstring);
i := pos(' ',cstring);
if i > 0 then
begin
ms := leftstr(cstring,i-1)+rightstr(cstring,j-i);//leftstr、rightstr为自定义取左、右字符串函数
result := ms;
ms := delspace(ms);
end
else
result := cstring;
end;