Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- int len = 0, lenMax = 0, index = 0;
- for(int i = 0; i < input.length(); i++) {
- switch(input.charAt(i)) {
- case ' ':
- len = 0;
- break;
- default:
- len++;
- if(len > lenMax) {
- lenMax = len;
- index = i;
- }
- }
- }
- System.out.println(input.substring(index - lenMax + 1, index + 1));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement