求帮忙编个回文问题
编程吧
全部回复
仅看楼主
level 1
回文问题:检测并输出一个文档中的回文单词.(要求用栈和队列实现)
2012年12月08日 16点12分 1
level 8
有三种方法,1朴素
2kmp2次拓展
3动态规划。
既然要设计栈就是朴素了
for i=1 to str.len
if str[i]<>zhan[zhantop] then
inc(zhantop)
zhan[zhantop]=str[i]
else
pd=true
while pd do
dec(zhantop)
inc(duitop)
duilie[duitop]=zhan[zhantop]
if zhan[zhantop]<>str[i] then pd=false
大概就这样,
2012年12月09日 04点12分 2
1