9 palindromic sequence verification

 

 

BOOL isPalindrome ( char * S) {
     int I, J, len; 
    len = strlen (S);
     IF (len <= . 1 ) // If there is a character string, but only if a subject compliance requirements, returns to true
         return  to true ; 
    
    for (I = 0 , J = len . 1 ; I < J;) 
    { 
        IF (! isalnum (S [I])) // this isalnum () is used to determine whether the alphanumeric characters, and if so returns 1, instead of returning 0 
        { 
            I ++ ;
             Continue ; 
        } 
        
        IF (! isalnum (S [J])) 
        { 
            J- ;
             Continue ; 
        } 
        
        IF (! Tolower (S [I]) = tolower (S [J])) // tolower () is a function for converting the capital letter lowercase, if it does not process the non-alphabetic 
        { 
            return  to false ; 
        } 
        the else 
        { 
            I ++ ; 
            J - ; 
        } 
    } 
    return  to true ; 
}

Comment: This question my initial idea, too, because This question is considered only letters and numbers, as long as the symbols and spaces can be removed, and then converted to uppercase letters and judgment is in line with the palindrome string to lowercase. I have to write to each part, and then found that it is very cumbersome. Online direct the caller to see the wording of the two functions so that the original code becomes simple. And I did not start to consider the case only if a letter

Guess you like

Origin www.cnblogs.com/181118ljh123/p/11978325.html