Advertisement
SergeyPGUTI

7.2.13

Nov 26th, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main {
  3.  
  4.  
  5.     static boolean  Palindrom(String a)
  6.     {
  7.         for(int i=0,Length=a.length(),j=(a.length()-1);i<j;i++,j--)
  8.         {
  9.             while (a.charAt(i)==' ') i++;
  10.             while (a.charAt(j)==' ') j--;
  11.             if (a.charAt(i)!=a.charAt(j)) return false;
  12.         }
  13.         return true;
  14.     }
  15.  
  16.     public static void main(String[] args) {
  17.         Scanner in = new Scanner(System.in);
  18.         String a=in.nextLine();
  19.         if (Palindrom(a)) System.out.print("YES");
  20.         else System.out.print("NO");
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement