Advertisement
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 scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- String[] inputArr = input.split("");
- String s = "";
- char[] letters = new char[inputArr.length - 1];
- for (String n : inputArr) {
- s += n;
- }
- letters = s.toCharArray();
- char[] check = {' ','a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
- int foundCount = 0;
- int notFound = 0;
- int sequence = 0;
- for (int i = 0; i < inputArr.length - 1; i++) {
- boolean isFound = false;
- for (int j = 0; j < check.length; j++) {
- if (letters[i] == check[j]) {
- isFound = true;
- break;
- }
- }
- if (!isFound) {
- notFound++;
- } else if (isFound && notFound > sequence) {
- sequence = notFound;
- notFound = 0;
- }
- if (i == inputArr.length - 2 && sequence == 0) {
- sequence = notFound;
- notFound = 0;
- }
- if (isFound) {
- notFound=0;
- }
- }
- System.out.println(sequence);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement