Mrgentledolphin

controlla palindromo

Feb 9th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. import java.util.*;
  2. public class Contrario {
  3.  
  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         String nome;
  7.         int a=0;
  8.         System.out.println("inserisci parola");
  9.         nome=input.nextLine();
  10.         input.close();
  11.        
  12.         for(int i=0; i<=nome.length()/2; i++){
  13.             if(nome.charAt(i)==nome.charAt(nome.length()-i-1)){
  14.                
  15.             }
  16.             else{
  17.                 a=1;
  18.             }
  19.            
  20.             }
  21.             if(a==0)
  22.                 System.out.println("è palindromo");
  23.             else
  24.                 System.out.println("non è palindromo");
  25.     }
  26. }
Add Comment
Please, Sign In to add comment