封装的方法栈方法:
https://www.cnblogs.com/LIXI-/p/16612874.html
判断回文数:
function isHuiwen(str) { let stack = new Stack(); for (let i = 0; i < str.length; i++) { stack.push(str[i]) } let newstr = "" while(!stack.isEmpty()){ newstr += stack.pop() } return str == newstr } console.log(isHuiwen("abcba"));
打印:
true
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/281802.html