Home > Back-end >  Whether palindrome judgment expressed as a character array of strings
Whether palindrome judgment expressed as a character array of strings

Time:10-10

import java.util.Scanner;
/* * determine whether expressed as a character array of strings for palindrome (left and right sides is symmetrical, such as level, deed, etc.) */
Public class Test02 {
Public static void main (String [] args) {
Scanner sc=new Scanner(System.in); System. The out. Print (" please input a string: ");
The String key=sc. NextLine ();
System. The out. Print (" please lose the length of the string: ");
Int N=sc. NextInt ();
Int m=0;
String [] s=new String [N].
for(int i=0; iIf (s [I]!=s/N - I - 1) {
M=1;
break;
}
}
If (m==1) {
System. The out. Println (" the string not palindrome ");
}
The else {
System. The out. Println (" this string palindrome ");
}}}

The inside of the for loop to judge conditions how to modify?

CodePudding user response:

String. ToCharArray, do you want to make a String into a character array, or String. The charAt
  • Related