Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Task10_7_2 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String s = sc.nextLine();
- lettersInWord(s);
- }
- public static void lettersInWord(String s) {
- int i = 0, j = s.length() - 1, res = 0;;
- while (i < s.length()) {
- if (s.charAt(i) == s.charAt(j)) {
- res = j;
- }
- j--;
- i++;
- }
- System.out.println(s.charAt(res));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment