Advertisement
aLT22

Полиндром

Dec 19th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Main{
  4.     static String input;
  5.     public static void main(String [] args){
  6.         Scanner reader = new Scanner(System.in);
  7.         String str1 = "", str2 = "";
  8.         System.out.print("Введите строку: ");
  9.         input = reader.nextLine();
  10.         char [] line = input.toCharArray();
  11.         for (int i = 0; i < (line.length / 2); i++){
  12.             str1.concat(Character.toString((line[i])));
  13.         }
  14.         for (int i = line.length - 1; i > ((line.length / 2)); i--){
  15.             str2.concat(Character.toString((line[i])));
  16.         }
  17.         if (str1.equals(str2)){
  18.             System.out.println("Полиндром!");
  19.         }
  20.         else {
  21.             System.out.println("Не полиндром!");
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement