Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Arrays;
- public class Game_1 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //Getting the phrase inside an array
- String a = scanner.nextLine();
- a = a.replace(" ", "");
- a = a.replace(".", "a");
- a = a.toLowerCase();
- String[] phrase = a.split("");
- //Getting the asci codes
- int[] asciArray = new int[phrase.length];
- for (int i = 0; i < asciArray.length; i++) {
- asciArray[i] = (int) a.charAt(i);
- }
- //Counting the longest sequence
- int max = 0;
- int sequence = 0;
- for (int i = 0; i < asciArray.length; i++) {
- boolean lampa = true;
- if ((asciArray[i] >= 48 && asciArray[i] <= 57)) {
- lampa = false;
- } else if ((asciArray[i] >= 97 && asciArray[i] <= 122)) {
- lampa = false;
- }
- if (lampa) {
- sequence++;
- } else {
- if (sequence > max) {
- max = sequence;
- }
- sequence = 0;
- }
- }
- if(sequence>max){
- max = sequence;
- }
- System.out.println(max);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement