MiniMi2022

Electronic Message

Mar 5th, 2022
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ElectronicMessage {
  4.     public static void main(String[] args) {
  5.         Scanner myScan = new Scanner(System.in);
  6.         char[] letters = myScan.nextLine().toCharArray();
  7.         int countMax = 0;
  8.         int counter = 0;
  9.         for (int i = 0; i < letters.length-1; i++) {
  10.             if (letters[i]!=32&&!Character.isLetterOrDigit(letters[i])) {
  11.                 counter++;
  12.             } else {
  13.                 counter = 0;
  14.             }
  15.             if (counter >= countMax) {
  16.                 countMax = counter;
  17.             }
  18.         }
  19.             System.out.print(countMax);
  20.     }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment