Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main{
- static String input;
- public static void main(String [] args){
- Scanner reader = new Scanner(System.in);
- String str1 = "", str2 = "";
- System.out.print("Введите строку: ");
- input = reader.nextLine();
- char [] line = input.toCharArray();
- for (int i = 0; i < (line.length / 2); i++){
- str1.concat(Character.toString((line[i])));
- }
- for (int i = line.length - 1; i > ((line.length / 2)); i--){
- str2.concat(Character.toString((line[i])));
- }
- if (str1.equals(str2)){
- System.out.println("Полиндром!");
- }
- else {
- System.out.println("Не полиндром!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement