Advertisement
madopew

Untitled

Jan 16th, 2020
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1.     public static void main(String[] args) {
  2.         Scanner scanner = new Scanner(System.in);
  3.         String input = scanner.nextLine();
  4.         int len = 0, lenMax = 0, index = 0;
  5.         for(int i = 0; i < input.length(); i++) {
  6.             switch(input.charAt(i)) {
  7.                 case ' ':
  8.                     len = 0;
  9.                     break;
  10.                 default:
  11.                     len++;
  12.                     if(len > lenMax) {
  13.                         lenMax = len;
  14.                         index = i;
  15.                     }
  16.             }
  17.         }
  18.         System.out.println(input.substring(index - lenMax + 1, index + 1));
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement