The third class, the class test

package three;
import java.util.Scanner;
   
    public class Huiwen {
        public static void main(String[]args){
        System.out.println("请输入需要判断字符串:");
        Scanner in = new Scanner(System.in);
        String str=in.next();
        int n=str.length();
        int m=huiwen(str,n);
        if(m==1)
        System.out.println("yes");
        else
        System.out.println("NO");
        } 
    Public  static  int Huiwen (STR String, int n-) {
         int A, B, J = 0 ;
         char C1, C2; 
        A = str.length () - n-; // shuffling 
        
        B = str.length () - ( +. 1 A);   // backfash 
        
        C1 = str.charAt (A);   // get the character 
        C2 = str.charAt (B);   // get the character 
        
        IF (C1 C2 || == A == B) = J 1;   // recursive 
        
        IF (A = B && A <B J == 1 &&! ) 
        Huiwen (STR, n- -1 );
         return J; 
        }
    }

As the code, the input string will be determined automatically whether a string is a palindrome.

Results are as follows:

 

 Setting a function to determine whether it is a palindromic string, the main function of the first length of the string is determined, a time length of the output string palindromic recursive manner.

Length for the moment, and determines the output function calls.

Guess you like

Origin www.cnblogs.com/520520520zl/p/11579607.html