| 发表于:2007-02-08 12:53:17 楼主 |
public class palindrome { static private string text; static private int firstindex; static private int lastindex; public static boolean ispalindrome(string text, int firstindex,int lastindex) { text = text.tolowercase(); firstindex = 0; lastindex = text.length()-1; for( int i=0; i < text.length(); i++) { char letter = text.charat(i); if(character.isletterordigit(letter) 这里 我要忽略标点和空格部分,但是怎么继续写下去呢?? } if (firstindex > = lastindex) return true; // base case else if (text.charat(firstindex) != text.charat(lastindex)) return false; else { return ispalindrome(text, firstindex + 1, lastindex -1); } } } |
|
|
|
|