Another interesting problem I stumbled across on reddit is finding the longest substring of a given string that is a palindrome. I found the explanation on Johan Jeuring's blog somewhat confusing and I had to spend some time poring over the Haskell code (eventually rewriting it in Python) and...
palindrome.js palindrome2.py pangram.c pangram__java phone.cpp portScanner.py prime.py primsminimumspannigtree.cpp print_elements_in_linkedlist.cpp pythagorastheorem-new.c quicksort.c random_infinite.bf random_integer.py roman_numerals.py roots of quadratic equation simple_intrest.cpp sum_of_tayl...
Finding next palindrome 而不是写作 else {pal(x+1);} write return pal(x+1); 如果第一个x+1不是回文,则当前pal函数不会返回任何值。根据@igorTandentik在评论中写的内容,这应该可以解决问题。 EDIT 1: 你的代码有一个严重的缺陷。你在while循环中把x设为零,然后将其与reverse进行比较,这永远不会是真...