Created
October 3, 2019 08:48
-
-
Save MariyaSokolskaya/e12ff20abba2aeb34f9d6e36cf07c40d to your computer and use it in GitHub Desktop.
Заготовка для задачи про палиндром
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
String s = "Madam, I'm Adam"; | |
String n = ""; // новая строка только из букв | |
for (int i = 0; i < s.length(); i++) { | |
char c = s.charAt(i); | |
if (Character.isLetter(c)) { | |
// если -i-ый символ - это буква | |
// приводим его к нижнему регистру, добавляем к строке n | |
c = Character.toLowerCase(c); | |
n += c; | |
} | |
} | |
System.out.println(n); | |
for (int i = 0; i < n.length() / 2; i++) { | |
// здесь проверка на палиндром | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment