看看这道题怎么做,有些拿不准

Delphi2C 2005-03-08 12:35:04
这道考试题大家帮忙给看看,先谢过了,试题如下:
回文字符串,如:aLEVELa
非回文字符串,如:aLEVELb
下面函数判断一个字符串是否是回文字符串,若是返回0,不是返回-1
function IS(const Word:String):Boolean;
var Pi,Pj:PChar;
begin
Pi:=PChar(Word);
Pi:=Pi+Length(Word)-1;
While (Pi<Pj) and (____________) do
begin
Inc(Pi);
Dec(Pj);
end;
Result:=___________;
end;
...全文
61 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Delphi2C 2005-03-08
  • 打赏
  • 举报
回复
多谢unsigned(僵哥)

题目写错了
Pi:=Pi+Length(Word)-1;
应该是
Pj:=Pi+Length(Word)-1;
僵哥 2005-03-08
  • 打赏
  • 举报
回复
function IS(const Word:String):Boolean;
var Pi,Pj:PChar;
begin
Pi:=PChar(Word);
Pi:=Pi+Length(Word)-1;
While (Pi<Pj) and (Pi^=Pj^) do
begin
Inc(Pi);
Dec(Pj);
end;
Result:=Pi^=Pj^;
end;

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧