Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ElectronicMessage {
- public static void main(String[] args) {
- Scanner myScan = new Scanner(System.in);
- char[] letters = myScan.nextLine().toCharArray();
- int countMax = 0;
- int counter = 0;
- for (int i = 0; i < letters.length-1; i++) {
- if (letters[i]!=32&&!Character.isLetterOrDigit(letters[i])) {
- counter++;
- } else {
- counter = 0;
- }
- if (counter >= countMax) {
- countMax = counter;
- }
- }
- System.out.print(countMax);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment