This commit is contained in:
JunkJumper 2020-09-02 14:34:03 +02:00
parent ef2317ac61
commit 414a649d02

28
src/TP1/Palindrome.java Normal file
View File

@ -0,0 +1,28 @@
package TP1;
import java.util.Scanner;
public class Palindrome {
public static String lire() {
String s;
Scanner sc = new Scanner(System.in);
s = sc.nextLine();
sc.close();
return s;
}
public static boolean pal(String s) {
if(s.length() == 0 || s.length() == 1) {
return true;
} else if(s.charAt(0) == s.charAt(s.length()-1)) {
return pal(s.substring(1, s.length()-2));
} else {
return false;
}
}
public static void main(String[] args) {
System.out.println(pal(lire()));
}
}