回文

public static boolean isPalindrome(String s){
		int i=0;int j=s.length()-1;
		boolean flag=true;
		while(i<j) {
			while (!(isLetterOrDigi(s.charAt(i)))&&i<j) {
				i++;
			}
			while (!(isLetterOrDigi(s.charAt(j)))&&i<j) {
				j--;
			}
			char ch1=s.charAt(i);
			char ch2=s.charAt(j);
			if ((ch1==ch2)||(ch1==ch2+32)||(ch2==ch1+32)) {
				i++;
				j--;
			}else {
				flag=false;
				break;
			}
			
		}
		return flag;
		
	}
	
	public static boolean isLetterOrDigi(char ch1){
		if ((ch1>=48&&ch1<=57)||(ch1>=65&&ch1<=90)||(ch1>=97&&ch1<=122)) {
			return true;
		}else {
			return false;
		}
	}
点赞